Example #1
0
    public static void sendMessage(AsyncTcpSession client, BasePacket packet)
    {
//		using (MemoryStream sendStream = new MemoryStream()) {
//			CodedOutputStream os = CodedOutputStream.CreateInstance(sendStream);
//          WriteMessageNoTag equivalent to WriteVarint32, WriteByte (byte [])
//          that is: variable length message header + message body
//			os.WriteMessageNoTag(request);
//			os.WriteRawBytes(bytes);
//			os.Flush();

        MemoryStream sendStream = new MemoryStream();

        packet.WriteTo(sendStream);
        byte[] bytes = sendStream.ToArray();
        client.Send(new ArraySegment <byte>(bytes));
//		}
    }
Example #2
0
    public static void sendMessage(AsyncTcpSession client, BasePacket packet)
    {
        //		using (MemoryStream sendStream = new MemoryStream()) {
        //			CodedOutputStream os = CodedOutputStream.CreateInstance(sendStream);
        // 			WriteMessageNoTag equivalent to WriteVarint32, WriteByte (byte [])
        // 			that is: variable length message header + message body
        //			os.WriteMessageNoTag(request);
        //			os.WriteRawBytes(bytes);
        //			os.Flush();

            MemoryStream sendStream = new MemoryStream();
            packet.WriteTo(sendStream);
            byte[] bytes = sendStream.ToArray();
            client.Send(new ArraySegment<byte>(bytes));
        //		}
    }