本文整理汇总了C#中ServerConnection.SendData方法的典型用法代码示例。如果您正苦于以下问题:C# ServerConnection.SendData方法的具体用法?C# ServerConnection.SendData怎么用?C# ServerConnection.SendData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.SendData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleDataReceived
static void HandleDataReceived(ServerConnection sender, DataEventArgs e)
{
/*
Interlocked.Increment(ref currencies);
byte[] temp = new byte[] { 0xAA, 0xBB, 0x00, 0x09, 0xA0, 0x0A, 0x00, 0x00, 0x00 };
sender.SendData(temp, 0, temp.Length);
return;
*/
/**/
byte[] datas = e.Data;
Interlocked.Increment(ref messages);
Interlocked.Add(ref bytes, datas.Length);
var msg = Message.ConvertFrom(datas);
//var line = e.Data.ToHexString();
//File.AppendAllText("data.txt", line + Environment.NewLine);
if (msg == null)
{
return;
}
if (msg.Datas == null)
{
msg.Datas = new byte[] { 0 };
}
byte flag = 0;
if (msg.Command == (int)CommandType.Beep)
{
UpdateDeviceInfo(msg, e.Device);
}
else if (msg.Command == (int)CommandType.Login)
{
if (msg.Device == null)
{
ServerInstrumentation.Current.LoginFailed();
if (!allowAllowAnonymous)
{
flag = 1;
sender.Disconnect();
return;
}
}
if (!allowAllowAnonymous || msg.Device != null)
{
UpdateDeviceInfo(msg, e.Device);
sender.AuthorizationType = Securtiy.AuthorizationType.Authorized;
}
}
else if (msg.Command == (int)CommandType.Detail)
{
Interlocked.Increment(ref currencies);
if (!allowAllowAnonymous && sender.AuthorizationType == Securtiy.AuthorizationType.Anonymous)
{
ServerInstrumentation.Current.Unregisted();
if (!allowAllowAnonymous)
{
sender.Disconnect();
return;
}
}
UpdateDeviceInfo(msg, e.Device);
e.Device.Increate();
if (msg.Currency != null)
{
DataPool.Push(msg.Currency);
}
}
else if (msg.Command == (int)CommandType.BlackTable)
{
}
else if (msg.Command == (int)CommandType.DownLoadBlackTable)
{
}
var data = msg.GetBytes(flag);
sender.SendData(data, 0, data.Length);
}