本文整理汇总了C#中IIPSocket类的典型用法代码示例。如果您正苦于以下问题:C# IIPSocket类的具体用法?C# IIPSocket怎么用?C# IIPSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IIPSocket类属于命名空间,在下文中一共展示了IIPSocket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RecvMoveStopHorizontal
void RecvMoveStopHorizontal(IIPSocket conn, BitStream r)
{
User user;
if ((user = TryGetUser(conn)) != null && (user.IsMovingLeft || user.IsMovingRight))
{
if (user.IsPeerTrading)
return;
user.StopMovingHorizontal();
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:10,代码来源:ServerPacketHandler.TopDown.cs
示例2: RecvMoveUp
void RecvMoveUp(IIPSocket conn, BitStream r)
{
User user;
if ((user = TryGetUser(conn)) != null && !user.IsMovingUp)
{
if (user.IsPeerTrading)
return;
user.MoveUp();
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:11,代码来源:ServerPacketHandler.TopDown.cs
示例3: RecvMoveStopVertical
void RecvMoveStopVertical(IIPSocket conn, BitStream r)
{
User user;
if ((user = TryGetUser(conn)) != null && (user.IsMovingUp || user.IsMovingDown))
{
if (user.IsPeerTrading)
return;
user.StopMovingVertical();
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:11,代码来源:ServerPacketHandler.TopDown.cs
示例4: RecvJump
void RecvJump(IIPSocket conn, BitStream r)
{
User user;
if (((user = TryGetUser(conn)) != null) && user.CanJump)
{
if (user.IsPeerTrading)
return;
user.Jump();
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:11,代码来源:ServerPacketHandler.SideScroller.cs
示例5: InvokeProcessor
/// <summary>
/// Invokes the <see cref="IMessageProcessor"/> for handle processing a message block.
/// </summary>
/// <param name="socket">The <see cref="IIPSocket"/> that the data came from.</param>
/// <param name="processor">The <see cref="IMessageProcessor"/> to invoke.</param>
/// <param name="reader">The <see cref="BitStream"/> containing the data to process.</param>
protected override void InvokeProcessor(IIPSocket socket, IMessageProcessor processor, BitStream reader)
{
// Invoke the processor as normal, but keeping track of the bit position before and after invoking
var startBits = reader.PositionBits;
base.InvokeProcessor(socket, processor, reader);
var endBits = reader.PositionBits;
// Update the stats
_stats.HandleProcessorInvoked(processor.MsgID, endBits - startBits);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:18,代码来源:StatMessageProcessorManager.cs
示例6: OnReceiveData
/// <summary>
/// When overridden in the derived class, allows for handling received data from an <see cref="IIPSocket"/>.
/// </summary>
/// <param name="sender">The <see cref="IIPSocket"/> that the data came from.</param>
/// <param name="data">The data that was received.</param>
protected override void OnReceiveData(IIPSocket sender, BitStream data)
{
base.OnReceiveData(sender, data);
try
{
// Process the data
_messageProcessorManager.Process(sender, data);
}
catch (Exception ex)
{
const string errmsg = "Failed to process received data from `{0}`. Exception: {1}";
if (log.IsWarnEnabled)
log.WarnFormat(errmsg, sender, ex);
Debug.Fail(string.Format(errmsg, sender, ex));
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:22,代码来源:ServerSockets.cs
示例7: OnReceiveData
/// <summary>
/// When overridden in the derived class, allows for handling received data from an <see cref="IIPSocket"/>.
/// </summary>
/// <param name="sender">The <see cref="IIPSocket"/> that the data came from.</param>
/// <param name="data">The data that was received. This <see cref="BitStream"/> instance is reused internally, so it
/// is vital that you do NOT hold a reference to it when this method returns. This should be no problem since you should
/// not be holding onto raw received data anyways, but if you must, you can always make a deep copy.</param>
protected virtual void OnReceiveData(IIPSocket sender, BitStream data)
{
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:10,代码来源:ClientSocketManager.cs
示例8: TryGetAccount
static IUserAccount TryGetAccount(IIPSocket conn)
{
// Check for a valid conn
if (conn == null)
{
const string errmsg = "conn is null.";
if (log.IsErrorEnabled)
log.Error(errmsg);
Debug.Fail(errmsg);
return null;
}
return conn.Tag as IUserAccount;
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:ServerPacketHandler.cs
示例9: RecvSendPrivateMessage
void RecvSendPrivateMessage(IIPSocket conn, BitStream r)
{
string TargetName = r.ReadString();
string Text = r.ReadString();
// Get the user to send the message to
User TargetChar = World.FindUser(TargetName);
string PrivateMessage = TargetName + " Says: " + Text;
using (var pw = ServerPacket.ReceivePrivateMessage(PrivateMessage))
{
TargetChar.Send(pw, ServerMessageType.GUIChat);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:16,代码来源:ServerPacketHandler.cs
示例10: RecvAcceptOrTurnInQuest
void RecvAcceptOrTurnInQuest(IIPSocket conn, BitStream r)
{
var providerIndex = r.ReadMapEntityIndex();
var questID = r.ReadQuestID();
// Get the user
User user;
if ((user = TryGetUser(conn)) == null || user.Map == null)
return;
if (user.IsPeerTrading)
return;
// Get the provider
var npc = user.Map.GetDynamicEntity<Character>(providerIndex);
var provider = npc as IQuestProvider<User>;
if (provider == null)
return;
// Check the distance and state
if (user.Map != npc.Map || user.Map == null || !npc.IsAlive || npc.IsDisposed ||
user.GetDistance(npc) > GameData.MaxNPCChatDistance)
return;
// Get the quest
var quest = _questManager.GetQuest(questID);
if (quest == null)
return;
// Ensure this provider even provides this quest
if (!provider.Quests.Contains(quest))
return;
// If the user already has the quest, try to turn it in
if (user.ActiveQuests.Contains(quest))
{
// Quest already started, try to turn in
var success = user.TryFinishQuest(quest);
using (var pw = ServerPacket.AcceptOrTurnInQuestReply(questID, success, false))
{
user.Send(pw, ServerMessageType.GUI);
}
}
else
{
// Quest not started yet, try to add it
var success = user.TryAddQuest(quest);
using (var pw = ServerPacket.AcceptOrTurnInQuestReply(questID, success, true))
{
user.Send(pw, ServerMessageType.GUI);
}
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:53,代码来源:ServerPacketHandler.cs
示例11: RecvUseWorld
void RecvUseWorld(IIPSocket conn, BitStream r)
{
var useEntityIndex = r.ReadMapEntityIndex();
// Get the map and user
User user;
Map map;
if (!TryGetMap(conn, out user, out map))
return;
if (user.IsPeerTrading)
return;
if (!user.IsAlive)
{
const string errmsg = "User `{0}` tried to use world entity while dead.";
if (log.IsInfoEnabled)
log.InfoFormat(errmsg, user);
return;
}
// Grab the DynamicEntity to use
var useEntity = map.GetDynamicEntity(useEntityIndex);
if (useEntity == null)
{
const string errmsg = "UseEntity received but usedEntityIndex `{0}` is not a valid DynamicEntity.";
Debug.Fail(string.Format(errmsg, useEntityIndex));
if (log.IsErrorEnabled)
log.ErrorFormat(errmsg, useEntityIndex);
return;
}
// Ensure the used DynamicEntity is even usable
var asUsable = useEntity as IUsableEntity;
if (asUsable == null)
{
const string errmsg =
"UseEntity received but useByIndex `{0}` refers to DynamicEntity `{1}` which does " +
"not implement IUsableEntity.";
Debug.Fail(string.Format(errmsg, useEntityIndex, useEntity));
if (log.IsErrorEnabled)
log.WarnFormat(errmsg, useEntityIndex, useEntity);
return;
}
// Use it
if (asUsable.Use(user))
{
// Notify everyone in the map it was used
if (asUsable.NotifyClientsOfUsage)
{
using (var pw = ServerPacket.UseEntity(useEntity.MapEntityIndex, user.MapEntityIndex))
{
map.Send(pw, ServerMessageType.Map);
}
}
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:58,代码来源:ServerPacketHandler.cs
示例12: RecvSelectAccountCharacter
void RecvSelectAccountCharacter(IIPSocket conn, BitStream r)
{
ThreadAsserts.IsMainThread();
var index = r.ReadByte();
// Ensure the client is in a valid state to select an account character
var userAccount = World.GetUserAccount(conn);
if (userAccount == null)
return;
if (userAccount.User != null)
{
const string errmsg = "Account `{0}` tried to change characters while a character was already selected.";
if (log.IsInfoEnabled)
log.InfoFormat(errmsg, userAccount);
return;
}
// Get the CharacterID
CharacterID characterID;
if (!userAccount.TryGetCharacterID(index, out characterID))
{
const string errmsg = "Invalid account character index `{0}` given.";
if (log.IsInfoEnabled)
log.InfoFormat(errmsg, characterID);
return;
}
// Load the user
userAccount.SetUser(World, characterID);
var user = userAccount.User;
if (user != null)
{
// Send the MOTD
if (!string.IsNullOrEmpty(ServerSettings.Default.MOTD))
{
using (var pw = ServerPacket.Chat(ServerSettings.Default.MOTD))
{
user.Send(pw, ServerMessageType.GUIChat);
}
}
// Send a notification to the world that the user joined
var param = new object[] {user.Name};
World.Send(GameMessage.UserJoinedWorld, ServerMessageType.GUIChat, param);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:51,代码来源:ServerPacketHandler.cs
示例13: RecvSay
void RecvSay(IIPSocket conn, BitStream r)
{
var text = r.ReadString(GameData.MaxClientSayLength);
User user;
if ((user = TryGetUser(conn)) == null)
return;
_sayHandler.Process(user, text);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:10,代码来源:ServerPacketHandler.cs
示例14: RecvRequestMapEntityIndex
void RecvRequestMapEntityIndex(IIPSocket conn, BitStream r)
{
var index = r.ReadMapEntityIndex();
// Get the user and their map
User user;
if ((user = TryGetUser(conn)) == null)
return;
Map map;
if (!TryGetMap(user, out map))
return;
// Get the DynamicEntity
var de = map.GetDynamicEntity(index);
if (de == null)
{
// The DynamicEntity for the index was null, so tell the client to delete whatever is at that index
using (var pw = ServerPacket.RemoveDynamicEntity(index))
{
conn.Send(pw, ServerMessageType.Map);
}
}
else
{
// A DynamicEntity does exist at that index, so tell the client to create it
using (var pw = ServerPacket.CreateDynamicEntity(de))
{
conn.Send(pw, ServerMessageType.Map);
}
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:33,代码来源:ServerPacketHandler.cs
示例15: RecvRaiseStat
void RecvRaiseStat(IIPSocket conn, BitStream r)
{
StatType statType;
// Get the StatType
try
{
statType = r.ReadEnum<StatType>();
}
catch (InvalidCastException)
{
const string errorMsg = "Received invaild StatType on connection `{0}`.";
Debug.Fail(string.Format(errorMsg, conn));
if (log.IsWarnEnabled)
log.WarnFormat(errorMsg, conn);
return;
}
// Get the User
User user;
if ((user = TryGetUser(conn)) == null)
return;
// Raise the user's stat
user.RaiseStat(statType);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:26,代码来源:ServerPacketHandler.cs
示例16: RecvUseInventoryItem
void RecvUseInventoryItem(IIPSocket conn, BitStream r)
{
var slot = r.ReadInventorySlot();
User user;
if ((user = TryGetUser(conn)) == null)
return;
user.UseInventoryItem(slot);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:10,代码来源:ServerPacketHandler.cs
示例17: RecvUseSkill
void RecvUseSkill(IIPSocket conn, BitStream r)
{
SkillType skillType;
MapEntityIndex? targetIndex = null;
// Get the SkillType to use
try
{
skillType = r.ReadEnum<SkillType>();
}
catch (InvalidCastException)
{
const string errmsg = "Failed to read SkillType from stream.";
if (log.IsWarnEnabled)
log.Warn(errmsg);
Debug.Fail(errmsg);
r.ReadBool();
return;
}
// Check for a target
var hasTarget = r.ReadBool();
if (hasTarget)
targetIndex = r.ReadMapEntityIndex();
// Get the user
User user;
if ((user = TryGetUser(conn)) != null)
{
// Check that they know the skill
if (!user.KnownSkills.Knows(skillType))
user.Send(GameMessage.SkillNotKnown, ServerMessageType.GUIChat);
else
{
// Use the skill
user.UseSkill(skillType, GetTargetCharacter(user, targetIndex));
}
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:39,代码来源:ServerPacketHandler.cs
示例18: RecvSelectNPCChatDialogResponse
void RecvSelectNPCChatDialogResponse(IIPSocket conn, BitStream r)
{
var responseIndex = r.ReadByte();
User user;
if ((user = TryGetUser(conn)) == null)
return;
user.ChatState.EnterResponse(responseIndex);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:10,代码来源:ServerPacketHandler.cs
示例19: RecvGetFriends
void RecvGetFriends(IIPSocket conn, BitStream r)
{
var account = TryGetAccount(conn);
if (account == null)
return;
User user;
if ((user = TryGetUser(conn)) == null)
return;
string FriendsString = account.Friends;
List<string> FriendsList = FriendsString.Split(',').ToList<string>();
string OnlineFriendsString = "";
string FriendsMap = "";
var OnlineMembers = Server.World.GetUsers();
foreach (var Member in OnlineMembers)
{
if (FriendsList.Contains(Member.Name))
{
OnlineFriendsString += Member.Name + ",";
var parentMap = World.GetMap(Member.Map.ParentMapID);
FriendsMap += parentMap.Name + ",";
}
}
using (var pw = ServerPacket.ReceiveFriends(OnlineFriendsString, FriendsMap, FriendsString))
{
user.Send(pw, ServerMessageType.GUI);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:33,代码来源:ServerPacketHandler.cs
示例20: RecvSellInventoryToShop
void RecvSellInventoryToShop(IIPSocket conn, BitStream r)
{
var slot = r.ReadInventorySlot();
var amount = r.ReadByte();
User user;
if ((user = TryGetUser(conn)) == null)
return;
user.ShoppingState.TrySellInventory(slot, amount);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:ServerPacketHandler.cs
注:本文中的IIPSocket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论