public static Task <WebsocketClient> Connect(string token, Statuses initialStatus) { var client = new WebsocketClient(token); client.targetStatus = initialStatus; return(client.connectTaskSource.Task); }
public static async Task <MarketClient> Connect(string token) { var client = new MarketClient(); client.apiClient = await ApiClient.Connect(token); if (client.apiClient != null) { client.websocketClient = await WebsocketClient.Connect(token, client.apiClient.InitialStatus); client.websocketClient.UserStatusChanged += client.WebsocketClient_UserStatusChanged; client.timer.Start(); return(client); } else { return(null); } }
public async Task CloseAsync() { if (this.timer != null) { this.timer.Dispose(); } if (this.websocketClient != null) { await this.websocketClient.CloseAsync(); } this.websocketClient = null; if (this.apiClient != null) { this.apiClient.Dispose(); } this.apiClient = null; }
public void Dispose() { if (this.timer != null) { this.timer.Dispose(); } this.timer = null; if (this.websocketClient != null) { this.websocketClient.Dispose(); } this.websocketClient = null; if (this.apiClient != null) { this.apiClient.Dispose(); } this.apiClient = null; }