这是我的方法:
public static void send(byte[] packet)
{
Console.Write(DateTime.Now.ToString() + ": ");
foreach (byte b in packet)
{
Console.Write(b.ToString("X2") + " ");
}
Console.WriteLine();
if (connected)
{
try
{
connection.Socket.Send(packet);
}
catch (Exception)
{
throw new Exception("Can't send packet");
}
}
}
这是来电者
public void addPacket(PacketProcessed packet)
{
int messageEvent = (int)Event.Type.Normal;
int speed = 0;
foreach (MessageProcessed message in packet.messages)
{
if ((currentlyEvent & (int)Event.Type.Speed) == (int)Event.Type.Speed)
{
if (Math.Abs(message.xSpeed) >= this.speedLimit - this.speedLimit * 0.1)
{
messageEvent |= (int)Event.Type.Speed;
speed = Math.Max(speed, (int)Math.Abs(message.xSpeed));
}
}
else
{
if (Math.Abs(message.xSpeed) >= this.speedLimit)
{
messageEvent |= (int)Event.Type.Speed;
speed = Math.Max(speed, (int)Math.Abs(message.xSpeed));
}
}
}
this.currentlyEvent = messageEvent;
if (this.currentlyEvent != historyEvent)
{
byte[] bb = ProtocolBuilder.buildProtocal(0xE0 + location, currentlyEvent, (byte)speed);
TCPTalker.send(bb); // <--- This line call above (send) method.
}
historyEvent = currentlyEvent;
packetStorage.Add(packet);
}
输出看起来像
~4/10/2013 3:10:59 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 44 E6 02 42
~4/10/2013 3:11:00 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E6 00 88
4/10/2013 3:11:00 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 45 E6 02 41
~~4/10/2013 3:11:04 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E6 00 88
~4/10/2013 3:11:05 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3C E3 02 4D
~4/10/2013 3:11:13 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
4/10/2013 3:11:13 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 41 E2 02 49
~~4/10/2013 3:11:18 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E3 00 8B
~4/10/2013 3:11:19 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 40 E6 02 46
~4/10/2013 3:11:24 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3D E3 02 4C
~4/10/2013 3:11:25 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E6 00 88
4/10/2013 3:11:25 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E3 00 8B
~~4/10/2013 3:11:26 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3D E3 02 4C
~4/10/2013 3:11:30 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
~4/10/2013 3:11:38 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 42 E6 02 44
~4/10/2013 3:11:44 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E3 00 8B
~4/10/2013 3:11:47 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3C E2 02 4E
~4/10/2013 3:11:50 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E6 00 88
~4/10/2013 3:11:56 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
4/10/2013 3:11:56 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3D E2 02 4D
~~4/10/2013 3:11:57 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
~4/10/2013 3:11:59 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 3C E2 02 4E
~4/10/2013 3:12:01 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
~4/10/2013 3:12:05 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 46 E2 02 44
~4/10/2013 3:12:12 PM: 7E 00 1A 10 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 46 3A 00 00 00 00 00 E2 00 8C
~
我看到“~”出现在我的调试字符串出现之前。有时输出窗口显示 ~ 然后 ~ 然后我的调试字符串看起来像 ~~4/10/2013 3:12:01 PM: 7E 00 ...
'~' 是什么意思?