private void SubscribeSocketsEvents() { connectedOpponents = new List <IUserPresence>(); _socket.ReceivedMatchmakerMatched += async matched => { Debug.LogFormat("Matched result: {0}", matched); _currMatch = await _socket.JoinMatchAsync(matched); _self = _currMatch.Self; Debug.LogFormat("Self: {0}", _self); connectedOpponents.AddRange(_currMatch.Presences); OnMatchJoins(_currMatch.Presences); }; // _socket.ReceivedMatchPresence += presenceEvent => { OnMatchLeaves(presenceEvent.Leaves); connectedOpponents.Remove(_self); OnMatchJoins(presenceEvent.Joins); UnityMainThread.wkr.AddJob(() => _player.SetName(_self.Username)); connectedOpponents.AddRange(presenceEvent.Joins); }; // var enc = System.Text.Encoding.UTF8; _socket.ReceivedMatchState += newState => { var content = enc.GetString(newState.State); var code = newState.OpCode.ToDataCode(); switch (newState.OpCode.ToDataCode()) { case DataCode.POSITION: Debug.Log("A custom opcode -- > NEW POSITION."); break; default: Debug.LogFormat("User '{0}'' sent '{1}'", newState.UserPresence.Username, content); break; } UnityMainThread.wkr.AddJob(() => { OnNewDataState(newState.UserPresence.UserId, code, content); }); BoxTextController.WriteText("Receive data--> " + content, Color.yellow); }; }