Ejemplo n.º 1
0
        private static void SendMessageHelper(ShrapnelMessage shrapnelMessage)
        {
            SocketClient socketClient = new SocketClient();

            //Conect to socket
            socketClient.Connect();

            // Send json length
            socketClient.Send(shrapnelMessage.PackUp(shrapnelMessage._jsonLengthUnsigned));

            // If there is a binary attachment, send length, else send 00
            if (shrapnelMessage._binaryLengthUnsigned > 0)
            {
                socketClient.Send(shrapnelMessage.PackUp(shrapnelMessage._jsonLengthUnsigned));
            }
            else
            {
                Byte[] noAttachment = new Byte[2];
                socketClient.Send(noAttachment);
            }

            //send json
            socketClient.Send(shrapnelMessage._jsonMessage);

            //send binary if it exists
            if (shrapnelMessage._binaryLengthUnsigned > 0)
            {
                socketClient.Send(shrapnelMessage._binaryAttachment);
            }
        }
Ejemplo n.º 2
0
 public static void SendMessage(String json_message, Byte[] binaryAttachment)
 {
     ShrapnelMessage shrapnelMessage = new ShrapnelMessage(json_message, binaryAttachment);
     SendMessageHelper(shrapnelMessage);
 }
Ejemplo n.º 3
0
 public static void SendMessage(String json_message)
 {
     ShrapnelMessage shrapnelMessage = new ShrapnelMessage(json_message);
     SendMessageHelper(shrapnelMessage);
 }