Exemple #1
0
        public async Task Connect()
        {
            //Try connect with wss connection
            Uri wssURI = new Uri(string.Format(ScatterConstants.WSURI,
                                               ScatterConstants.WSS_PROTOCOL,
                                               ScatterConstants.WSS_HOST,
                                               ScatterConstants.WSS_PORT));

            bool linked = await SocketService.Link(wssURI);

            if (!linked)
            {
                //try normal ws connection
                Uri wsURI = new Uri(string.Format(ScatterConstants.WSURI,
                                                  ScatterConstants.WS_PROTOCOL,
                                                  ScatterConstants.WS_HOST,
                                                  ScatterConstants.WS_PORT));

                linked = await SocketService.Link(wsURI);

                //TODO check for errors
                if (!linked)
                {
                    throw new Exception("socket not available.");
                }
            }

            this.Identity = await this.GetIdentityFromPermissions();
        }
Exemple #2
0
        public async Task Connect(CancellationToken?cancellationToken = null)
        {
            try
            {
                //Try connect with wss connection
                Uri wssURI = new Uri(string.Format(WSURI, "wss", "local.get-scatter.com", "50006"));
                await SocketService.Link(wssURI, cancellationToken);
            }
            catch (WebSocketException)
            {
                //try normal ws connection
                SocketService = new SocketService(new MemoryStorageProvider(), AppName);
                Uri wsURI = new Uri(string.Format(WSURI, "ws", "127.0.0.1", "50005"));
                await SocketService.Link(wsURI, cancellationToken);
            }

            this.Identity = await this.GetIdentityFromPermissions();
        }