public static void SendData(MessagePacket mp) { MemoryStream stream = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(MessagePacket)); ser.WriteObject(stream, mp); var packet = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length); client.SendData(packet); }
public static void SendDataBroadNotSelf(string data) { MessagePacket mp = new MessagePacket(); mp.D = data; mp.T = (int)SendMode.SendBroadNotSelf; MemoryStream stream = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(MessagePacket)); ser.WriteObject(stream, mp); var packet = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length); client.SendData(packet); }