public void SendMsg(BodyMsg body, List <Socket> list = null) { MessageData data = new MessageData(); HeadMsg head = new HeadMsg(); data.Head = head; data.Body = body; ByteBuffer _buff = new ByteBuffer(); byte[] bytes = StaticTools.Serialize(data); _buff.WriteInt32(bytes.Length); _buff.WriteBytes(bytes); bytes = _buff.ToBytes(); if (list == null) { list = GlobalData.GetAllPlayer(); } foreach (var socket in list) { if (socket.Connected) { socket.Send(bytes); } } }
public static void SendMsg(int cmd, int scmd, BodyMsg body) { MessageData data = new MessageData(); HeadMsg head = new HeadMsg(); data.Head = head; data.Body = body; ByteBuffer _buff = new ByteBuffer(); byte[] bytes = StaticTools.Serialize(data); _buff.WriteInt32(bytes.Length); _buff.WriteBytes(bytes); bytes = _buff.ToBytes(); socket.Send(bytes); }