Ejemplo n.º 1
0
        public PayLoad OnMessage(GingerSocket.eProtocolMessageType MessageType, object obj = null)
        {
            MessageEventHandler handler = Message;

            if (handler != null)
            {
                MessageEventArgs EVArgs = new MessageEventArgs(MessageType, obj);
                handler(this, EVArgs);

                if (IsGingerSocketLogging)
                {
                    GingerSocketLog GSL = new GingerSocketLog();
                    GSL.TimeStamp = DateTime.Now;
                    GSL.Name      = MessageType.ToString();
                    GSL.Info      = obj.ToString();
                    GSL.LogType   = "Message";
                    GingerSocketLogs.Add(GSL);
                }
                return(EVArgs.Response);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public void OnMessage(GingerSocket.eProtocolMessageType MessageType, object obj = null)
        {
            MessageEventHandler handler = Message;

            if (handler != null)
            {
                handler(this, new MessageEventArgs(MessageType, obj));
            }

            if (IsGingerSocketLogging)
            {
                GingerSocketLog GSL = new GingerSocketLog();
                GSL.Name    = MessageType.ToString();
                GSL.Info    = obj.ToString();
                GSL.LogType = "Message";
                GingerSocketLogs.Add(GSL);
            }
        }
Ejemplo n.º 3
0
        public PayLoad SendPayLoad(PayLoad pl)
        {
            if (IsGingerSocketLogging)
            {
                GingerSocketLog GSL = new GingerSocketLog();
                GSL.LogType = "Send";
                GSL.SetPayLoad(pl);
                GingerSocketLogs.Add(GSL);
            }

            try
            {
                Stopwatch st = new Stopwatch();
                st.Start();
                GingerSocket.Send(mNetworkStream, pl);
                PayLoad plrc = GingerSocket.ReadPayLoad(mClientSocket);
                st.Stop();

                if (IsGingerSocketLogging)
                {
                    GingerSocketLog GSL = new GingerSocketLog();
                    GSL.SetPayLoad(plrc);
                    GSL.LogType = "Recv";
                    GSL.Elapsed = st.ElapsedMilliseconds;

                    GingerSocketLogs.Add(GSL);
                }

                return(plrc);
            }
            catch (Exception ex)
            {
                // Raise event so consumer can show a message or close nicely or retry connect
                OnMessage(GingerSocket.eProtocolMessageType.CommunicationError, ex.Message);
                return(PayLoad.Error("Error in SendPayLoad:" + ex.Message));
            }
        }
Ejemplo n.º 4
0
        private void ResendButton_Click(object sender, RoutedEventArgs e)
        {
            GingerSocketLog GSL = (GingerSocketLog)MainGrid.SelectedItem;

            mGingerSocketClient.SendPayLoad(GSL.PayLoad);
        }