public static Task <WebsocketClient> Connect(string token, Statuses initialStatus)
        {
            var client = new WebsocketClient(token);

            client.targetStatus = initialStatus;
            return(client.connectTaskSource.Task);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }