Esempio 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);
            }
        }
Esempio n. 2
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Set the data context of the listbox control to the sample data
            DataContext = App.ViewModel;
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

            //Create a socket
            //SocketClient _sc = new SocketClient();

            // Test the receive functionality
            //_sc.TestWrite();

            //Test JSON Writing capabilities
            //JSONHandler handle = new JSONHandler();
            //handle.Test();

            //Test Binary length writing capabilities
            //Person bob = new Person("Ted", "Haanson");
            //ShrapnelHandler.SendMessage(JSONHandler.ObjectToJSON<Person>(bob));

            //Test receiving functionality
            SocketClient sc = new SocketClient();
            sc.Connect();
            sc.Receive();
        }