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); } }; }
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); } }; }
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); } }; }
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); }
public WSClientBase(WSApiBase <TUser, TToken> api, IWSBase ws) { _api = api; _ws = ws; }
public RestProtocolClient(IWSBase ws, string name) { _ws = ws; _name = name; }