本文整理汇总了C#中Pici.Messages.ServerMessage.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# ServerMessage.GetBytes方法的具体用法?C# ServerMessage.GetBytes怎么用?C# ServerMessage.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pici.Messages.ServerMessage
的用法示例。
在下文中一共展示了ServerMessage.GetBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendNotif
internal void SendNotif(string Message, Boolean FromHotelManager)
{
ServerMessage nMessage = new ServerMessage();
if (FromHotelManager)
{
nMessage.Init(139);
}
else
{
nMessage.Init(161);
}
nMessage.AppendStringWithBreak(Message);
GetConnection().SendData(nMessage.GetBytes());
}
示例2: UnsafeSendMessage
internal void UnsafeSendMessage(ServerMessage Message)
{
if (Message == null)
return;
if (GetConnection() == null)
return;
GetConnection().SendUnsafeData(Message.GetBytes());
}
示例3: appendResponse
internal void appendResponse(ServerMessage message)
{
Appends(message.GetBytes());
}
示例4: SendBanMessage
internal void SendBanMessage(string Message)
{
ServerMessage BanMessage = new ServerMessage(35);
BanMessage.AppendStringWithBreak(LanguageLocale.GetValue("moderation.banmessage"), 13);
BanMessage.AppendStringWithBreak(Message);
GetConnection().SendData(BanMessage.GetBytes());
}
示例5: commands
internal void commands()
{
ServerMessage nMessage = new ServerMessage();
nMessage.Init(810);
nMessage.Append(1);
nMessage.Append(ChatCommandRegister.GenerateCommandList(Session));
Session.GetConnection().SendData(nMessage.GetBytes());
}
示例6: TestClientConnections
private void TestClientConnections()
{
TimeSpan sinceLastTime = DateTime.Now - pingLastExecution;
if (sinceLastTime.TotalMilliseconds >= pingInterval)
{
try
{
ServerMessage PingMessage = new ServerMessage(50);
List<GameClient> ToPing = new List<GameClient>();
//List<GameClient> ToDisconnect = new List<GameClient>();
TimeSpan noise;
TimeSpan sinceLastPing;
foreach (GameClient client in clients.Values)
{
noise = DateTime.Now - pingLastExecution.AddMilliseconds(pingInterval); //For finding out if there is any lagg
sinceLastPing = DateTime.Now - client.TimePingedReceived;
if (sinceLastPing.TotalMilliseconds - noise.TotalMilliseconds < pingInterval + 10000)
{
ToPing.Add(client);
}
else
{
lock (timedOutConnections.SyncRoot)
{
timedOutConnections.Enqueue(client);
}
//ToDisconnect.Add(client);
//Console.WriteLine(client.ConnectionID + " => Connection timed out");
}
}
DateTime start = DateTime.Now;
byte[] PingMessageBytes = PingMessage.GetBytes();
foreach (GameClient Client in ToPing)
{
try
{
Client.GetConnection().SendUnsafeData(PingMessageBytes);
}
catch
{
//ToDisconnect.Add(Client);
lock (timedOutConnections.SyncRoot)
{
timedOutConnections.Enqueue(Client);
}
}
}
TimeSpan spent = DateTime.Now - start;
if (spent.TotalSeconds > 3)
{
Console.WriteLine("Spent seconds on testing: " + (int)spent.TotalSeconds);
}
//start = DateTime.Now;
//foreach (GameClient client in ToDisconnect)
//{
// try
// {
// client.Disconnect();
// }
// catch { }
//}
//spent = DateTime.Now - start;
if (spent.TotalSeconds > 3)
{
Console.WriteLine("Spent seconds on disconnecting: " + (int)spent.TotalSeconds);
}
//ToDisconnect.Clear();
//ToDisconnect = null;
ToPing.Clear();
ToPing = null;
}
catch (Exception e) { Logging.LogThreadException(e.ToString(), "Connection checker task"); }
pingLastExecution = DateTime.Now;
}
}
示例7: SendMessageToUsersWithRights
internal void SendMessageToUsersWithRights(ServerMessage Message)
{
try
{
byte[] PacketData = Message.GetBytes();
foreach (RoomUser user in roomUserManager.UserList.Values)
{
if (user.IsBot)
continue;
GameClient UsersClient = user.GetClient();
if (UsersClient == null)
continue;
if (!CheckRights(UsersClient))
continue;
try
{
UsersClient.GetConnection().SendData(PacketData);
}
catch (Exception e) { Logging.HandleException(e, "Room.SendMessageToUsersWithRights"); }
//User.GetClient().SendMessage(Message);
}
}
catch (Exception e) { Logging.HandleException(e, "Room.SendMessageToUsersWithRights"); }
}
示例8: SendMessage
internal void SendMessage(ServerMessage Message)
{
try
{
if (Message == null)
return;
byte[] PacketData = Message.GetBytes();
lock (roomServerMessages.SyncRoot)
{
roomServerMessages.Enqueue(PacketData);
}
}
catch (InvalidOperationException e) { Logging.HandleException(e, "Room.SendMessage"); }
}
示例9: QueueRoomMessage
internal void QueueRoomMessage(ServerMessage message)
{
lock (roomServerMessages.SyncRoot)
{
roomServerMessages.Enqueue(message.GetBytes());
}
}