本文整理汇总了C#中NetworkClient.SendChatData方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.SendChatData方法的具体用法?C# NetworkClient.SendChatData怎么用?C# NetworkClient.SendChatData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.SendChatData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
DateTime now = DateTime.Now;
ChatMessage[] outChatMessages = _outChatMessages.Where(cm => cm.MessageTime <= now ).ToArray();
if (outChatMessages.Length > 0)
{
foreach (ChatMessage chatMessage in outChatMessages)
{
_outChatMessages.Remove(chatMessage);
//1: From, 2: To, 3: Type, 4: Message
string message = Packet.BuildPacket(FromClient.CHAT_MESSAGE,
Chat.POST, client.Login, chatMessage.Sender, chatMessage.Type,
chatMessage.Message);
networkClient.SendChatData(message);
//Play notification for private message
_soundPlayer.Play();
//Out chat message
string logMessage = string.Format("[{0}] {1} [{2}] {3}",
client.Login,
chatMessage.Type == ChatMessageType.Pivate ? "private" : "to",
chatMessage.Sender, chatMessage.Message);
networkClient.OutChatMessage(logMessage);
}
return true;
}
return false;
}
示例2: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
int curTickCount = Environment.TickCount;
//Just started
if (_prewPingTime == 0)
{
_prewPingTime = curTickCount;
return false;
}
if (curTickCount - _prewPingTime >= PING_DELAY_MS)
{
//Query params: 0: is a first time ping?, [1]: I1, [2]: ID2, [3]: ID1
string ping = Packet.BuildPacket(FromClient.PING,
_firstTime,
client.AdditionalData[ObjectPropertyName.I1][0],
client.AdditionalData[ObjectPropertyName.ID2][0],
client.AdditionalData[ObjectPropertyName.ID1][0]);
networkClient.SendData(ping);
networkClient.SendChatData(ping);
_firstTime = false;
_prewPingTime = Environment.TickCount;
return true;
}
return false;
}
示例3: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
bool chatStarted = false;
networkClient.OutLogMessage("Starting chat...");
//Get chat info
string getInfo = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.START);
networkClient.SendData(getInfo);
//Start chat
Packet chat = networkClient.InputQueue.Pop(FromServer.CHAT_CTRL);
if (chat != null)
{
string chatServer = chat["@server"];
string sessionId = (string)client.AdditionalData[ObjectPropertyName.SESSION_ID][0];
chatStarted = networkClient.StartChat(chatServer, sessionId);
if (chatStarted)
{
//1: Session ID, 2: Login
string chatAuth = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.AUTH,
sessionId, client.Login);
networkClient.SendChatData(chatAuth);
}
}
networkClient.OutLogMessage(!chatStarted
? "WARNING: chat wasn`t started"
: "Chat was successfully started");
return true;
}