本文整理汇总了C#中User.Send方法的典型用法代码示例。如果您正苦于以下问题:C# User.Send方法的具体用法?C# User.Send怎么用?C# User.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.Send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForceSynchronizeTo
public virtual void ForceSynchronizeTo(User user)
{
using (var pw = ServerPacket.GetWriter())
{
ServerPacket.SetCharacterHPPercent(pw, _character.MapEntityIndex, _lastSentHPPercent);
ServerPacket.SetCharacterMPPercent(pw, _character.MapEntityIndex, _lastSentMPPercent);
user.Send(pw, ServerMessageType.MapCharacterSP);
}
}
示例2: RecoverLostTradeItems
/// <summary>
/// Recovers items from the <see cref="ActiveTradeItemTable"/> for a character, and gives them to the character. Items can
/// get stuck in this table when the server unexpectedly shuts down during a peer trade session. Calling this method
/// will attempt to give the <see cref="Character"/> any items they might have in this table. This cannot be done if the
/// <paramref name="character"/> is currently trading.
/// </summary>
/// <param name="character">The <see cref="Character"/> to get the lost items for.</param>
/// <param name="recovered">The number of items that were able to be given back to the <paramref name="character"/>.</param>
/// <param name="remaining">The number of items still remaining in the table for the <paramref name="character"/>.</param>
/// <exception cref="ArgumentNullException"><paramref name="character"/> is null.</exception>
public static void RecoverLostTradeItems(User character, out int recovered, out int remaining)
{
recovered = 0;
if (character == null)
throw new ArgumentNullException("character");
// Make sure that we do not try executing this while they are trading! Doing so would be very, very ugly.
if (character.IsPeerTrading)
{
const string errmsg = "Tried to recover lost trade items for `{0}` while they were trading. Very bad idea...";
if (log.IsWarnEnabled)
log.WarnFormat(errmsg, character);
remaining = 0;
return;
}
// Get the list of lost items
var lostItemIDs = _getLostItemsQuery.Execute(character.ID);
// Check if there are even any items to recover
remaining = lostItemIDs.Count();
if (remaining == 0)
return;
// One by one, try to add the lost items back to the character
foreach (var lostItemID in lostItemIDs)
{
// Create the item instance
var lostItem = ItemEntity.LoadFromDatabase(lostItemID);
// Remove the entry from the table containing the lost items
_removeItemQuery.Execute(lostItemID);
remaining--;
// Make sure the item was valid (which it should always be unless something went horribly wrong)
// We do NOT try to add it back again, since who knows what is wrong with the item... its just not worth risking
if (lostItem == null)
{
Debug.Fail("Why did we fail to load the item... from a RELATIONAL database!?");
continue;
}
recovered++;
// Try to give the item to the character
var lostItemRemainder = character.TryGiveItem(lostItem);
// If there was a remainder when we tried to give the character the item, then we will have to put it back into the
// database table so we can try to give it to them again another time.
if (lostItemRemainder != null)
{
_insertItemQuery.Execute(new PeerTradingInsertItemQuery.QueryArgs(lostItemRemainder.ID, character.ID));
remaining++;
break;
}
}
// Notify the character about the items recovered and remaining
if (remaining > 0)
character.Send(GameMessage.PeerTradingItemsRecovered, ServerMessageType.GUI, recovered, remaining);
else
character.Send(GameMessage.PeerTradingItemsRecoveredNoRemaining, ServerMessageType.GUI, recovered);
}
示例3: SendMapData
/// <summary>
/// Sends the data to the specified user of all existing content on the map.
/// </summary>
/// <param name="user">User to send the map data to.</param>
void SendMapData(User user)
{
using (var pw = ServerPacket.GetWriter())
{
// Tell the user to change the map
ServerPacket.SetMap(pw, ID);
user.Send(pw, ServerMessageType.Map);
// Send dynamic entities
foreach (var dynamicEntity in DynamicEntities)
{
pw.Reset();
ServerPacket.CreateDynamicEntity(pw, dynamicEntity);
user.Send(pw, ServerMessageType.Map);
// Perform special synchronizations for Characters
var character = dynamicEntity as Character;
if (character != null)
{
character.SynchronizeSPTo(user);
character.SynchronizePaperdollTo(user);
}
}
// Now that the user know about the Map and every Entity on it, tell them which one is theirs
pw.Reset();
ServerPacket.SetUserChar(pw, user.MapEntityIndex);
user.Send(pw, ServerMessageType.Map);
}
}
示例4: Send
/// <summary>
/// 向某客户端发送信息
/// </summary>
/// <param name="toSend">欲接受信息的客户端</param>
/// <param name="msg">欲发送的信息</param>
/// <returns></returns>
public bool Send(User toSend, string msg)
{
return toSend.Send(msg);
}