Exemplo n.º 1
0
        public WSApiBase()
        {
            _ws   = new SocketIOClient();
            _auth = new AuthClient <TUser, TToken>(this, _ws);
            _hub  = new HubClient <TUser, TToken>(this, _ws);
            _rest = new RestClient <TUser, TToken>(this, _ws);

            Ws.EventNewSocketInstance += (s, e) =>
            {
                Auth.Init();
                Hub.Init();
                Rest.Init();
            };
            Auth.EventWSError += (s, e) => { if (EventWSError != null)
                                             {
                                                 EventWSError(this, e);
                                             }
            };
            Rest.EventWSError += (s, e) => { if (EventWSError != null)
                                             {
                                                 EventWSError(this, e);
                                             }
            };
            Hub.EventWSError += (s, e) => { if (EventWSError != null)
                                            {
                                                EventWSError(this, e);
                                            }
            };
        }
Exemplo n.º 2
0
 public HubClient(WSApiBase <TUser, TToken> api, IWSBase ws)
     : base(api, ws)
 {
     _restProtocol = new RestProtocolClient <HubRequest, HubResponse>(ws, "hub");
     _restProtocol.EventWSError += (s, e) => { if (EventWSError != null)
                                               {
                                                   EventWSError(this, e);
                                               }
     };
     _restProtocol.EventResponseError += (s, e) => { if (EventResponseError != null)
                                                     {
                                                         EventResponseError(this, e);
                                                     }
     };
 }
Exemplo n.º 3
0
 public RestClient(WSApiBase <TUser, TToken> api, IWSBase ws)
     : base(api, ws)
 {
     _restProtocol = new RestProtocolClient <RestRequest, object>(ws, "rest");
     _restProtocol.EventWSError += (s, e) => { if (EventWSError != null)
                                               {
                                                   EventWSError(this, e);
                                               }
     };
     _restProtocol.EventResponseError += (s, e) => { if (EventResponseError != null)
                                                     {
                                                         EventResponseError(this, e);
                                                     }
     };
 }
Exemplo n.º 4
0
 public AuthClient(WSApiBase <TUser, TToken> api, IWSBase ws)
     : base(api, ws)
 {
     _restProtocol = new RestProtocolClient <AuthRequest, AuthResponse <TUser, TToken> >(ws, "auth");
     _restProtocol.EventWSError += (s, e) => { if (EventWSError != null)
                                               {
                                                   EventWSError(this, e);
                                               }
     };
     _restProtocol.EventResponseError += (s, e) => { if (EventResponseError != null)
                                                     {
                                                         EventResponseError(this, e);
                                                     }
     };
     ws.EventConnectionChange += async(s, e) =>
     {
         if (this.AuthInfo != null && e.Value)
         {
             try
             {
                 await Authenticate(AuthInfo.token);
             }
             catch (Exception ex)
             {
                 if (EventWSError != null)
                 {
                     EventWSError(this, new EventArgs <WSError>(new WSError(WSErrorCode.ws_auth_invalid_credentials, ex.Message)));
                 }
             }
         }
         else
         {
             SetIsAuthenticate(false);
         }
     };
     ws.EventDisconnect += (s, e) => SetIsAuthenticate(false);
 }
Exemplo n.º 5
0
 public WSClientBase(WSApiBase <TUser, TToken> api, IWSBase ws)
 {
     _api = api;
     _ws  = ws;
 }
Exemplo n.º 6
0
 public RestProtocolClient(IWSBase ws, string name)
 {
     _ws   = ws;
     _name = name;
 }