Beispiel #1
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);
                                                     }
     };
 }
Beispiel #2
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);
                                                     }
     };
 }
Beispiel #3
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);
 }