コード例 #1
0
 public override void WebSocketDidOpen(SRWebSocket webSocket)
 {
     System.Diagnostics.Debug.WriteLine(@"WebSocket connection opened.");
     SetState(ARDWebSocketChannelState.kARDWebSocketChannelStateOpen);
     if (!string.IsNullOrEmpty(_roomId) && !string.IsNullOrEmpty(_clientId))
     {
         RegisterWithCollider(_roomId, _clientId);
     }
 }
コード例 #2
0
 public override void ViewDidLoad()
 {
     //	 _socket = [[SRWebSocket alloc] initWithURL:url];
     _socket = new SRWebSocket(new NSUrlRequest(new NSUrl(_socketUrl)));
     //_socket.delegate = self;
     //NSLog(@"Opening WebSocket.");
     base.ViewDidLoad();
     // Perform any additional setup after loading the view, typically from a nib.
 }
コード例 #3
0
 public ARDWebSocketChannel(string webSocketUrl, string webSockerRestUrl, IARDWebSocketChannelDelegate @delegate)
 {
     _webSocketUrl     = webSocketUrl;
     _webSockerRestUrl = webSockerRestUrl;
     _delegate         = @delegate;
     _socket           = new SRWebSocket(new NSUrl(_webSocketUrl));
     _socket.Delegate  = this;
     System.Diagnostics.Debug.WriteLine("Opening WebSocket.");
     _socket.Open();
 }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.

            socket = new SRWebSocket(new NSUrl("ws://localhost:9000/chat"));
            socket.MessageReceived += HandleMessageReceived;
            socket.Open();

            TableView.DataSource = new TestChatDataSource(messages);

            inputView.BecomeFirstResponder();

            inputView.Changed += HandleInputChanged;
        }
コード例 #5
0
        //didReceiveMessage
        public override void WebSocket(SRWebSocket webSocket, NSObject message)
        {
            SocketResponse socketResponse;

            try
            {
                socketResponse = JsonConvert.DeserializeObject <SocketResponse>(message.ToString());
                if (!string.IsNullOrEmpty(socketResponse.error))
                {
                    System.Diagnostics.Debug.WriteLine($"WSS error: {socketResponse.error}");
                    return;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Invalid json  error: {ex.Message}");
                return;
            }

            System.Diagnostics.Debug.WriteLine(@"WSS->C: %@", socketResponse.msg);
            ARDSignalingMessage signalingMessage = ARDSignalingMessageExtensions.MessageFromJSONString(socketResponse.msg);

            _delegate.DidReceiveMessage(signalingMessage);
        }