Exemple #1
0
        public void Connect()
        {
            client          = new WebSocketSharp.WebSocket(config.EnpointUri);
            client.WaitTime = new TimeSpan(0, 0, config.KeepAliveInSeconds);

            client.OnMessage += (sender, e) =>
            {
                SSAPMessage <SSAPBodyMessage> message = SSAPMessage <SSAPBodyMessage> .FromJson <SSAPBodyMessage>(e.Data);

                if (message.MessageType != SSAPMessageTypesEnum.INDICATION)
                {
                    Callback c;
                    callbacks.TryDequeue(out c);
                    c.Handle(e.Data);
                }
                else
                {
                    foreach (IListener4SIBIndicationNotifications listener in subscriptionListeners)
                    {
                        Action a = () => { listener.OnIndication("", message); };
                        Task.Factory.StartNew(a);
                    }
                }
            };
            client.Connect();
        }
Exemple #2
0
        public SSAPMessage <SSAPBodyReturnMessage> Send <T>(SSAPMessage <T> request) where T : SSAPBodyMessage
        {
            lock (thisLock)
            {
                string   strRequest = request.ToJson();
                Callback callback   = new Callback(config.TimeOutConnectionSIB);
                callbacks.Enqueue(callback);
                client.Send(strRequest);
                string strResponse = callback.Get();
                SSAPMessage <SSAPBodyReturnMessage> response = SSAPMessage <SSAPBodyReturnMessage> .FromJson <SSAPBodyReturnMessage>(strResponse);

                return(response);
            }
        }