public void _startPhase() { for (int i = 0; i < added.Count; i++) { try { added[i].Start(); } catch (Exception e) { Debugger.LogError(string.Format("{0} {1}", e.Message, e.StackTrace)); } } added.Clear(); }
protected override void OnPeerConnected(IPeer peer) { try { // join game after connected if (game != null) { if (game.status == GameStatus.WaitToInitialize) { debugger.Log("Start initialize game."); game.Initialize().Wait(); debugger.Log("End initialize game."); } if (game.status == GameStatus.WaitToStart) { debugger.Log("Start game."); game.Start(); } } debugger.Log("Join game."); game.JoinAsync(peer, null) .ContinueWith((res) => OnPeerJoinResponse(peer, res.Result)); } catch (Exception e) { debugger.LogError(e); } }
/// <summary> /// 打印错误 /// </summary> /// <param name="message">消息</param> public void LogError(object message) { if (!HasLevel(DebugLevel.Error)) { return; } debugger.LogError(message); }
private void OnClientReceivePacketEvent(object obj, Reliability reliability) { GenericPacket packet = obj as GenericPacket; if (packet != null) { if (receivers.TryGetValue(packet.InstCode, out List <IPacketReceiver> receiverList)) { try { foreach (var receiver in receiverList) { receiver.Receive(packet.Data); } } catch (Exception e) { debugger.LogError(e.Message + e.StackTrace); } } if (actions.TryGetValue(packet.InstCode, out List <Action <object> > actionList)) { foreach (var action in actionList) { try { action.Invoke(packet.Data); } catch (Exception e) { debugger.Log(e.Message + e.StackTrace); } } } } else { debugger.Log("Packet is null."); } }
public async Task <JoinGroupResponse> JoinAsync(IPeer peer, object arg) { // check if group is closed if (isClosed) { return(new JoinGroupResponse(GroupId, OperationCode, JoinGroupResponse.ResultType.Cancelled, string.Format("Group is closed."))); } // check if peer has joined if (peers.ContainsKey(peer.Id)) { return(new JoinGroupResponse(GroupId, OperationCode, JoinGroupResponse.ResultType.HasJoined, string.Format("Has joined in group"))); } // check if peer is in queue if (joinQueuing.Exists(req => req.Peer.Id == peer.Id)) { return(new JoinGroupResponse(GroupId, OperationCode, JoinGroupResponse.ResultType.InQueue, string.Format("Join request is in queue."))); } // check if peer is been handling if (joinHandling.Exists(req => req.Peer.Id == peer.Id)) { return(new JoinGroupResponse(GroupId, OperationCode, JoinGroupResponse.ResultType.Handling, string.Format("Join request is handling."))); } // add request into queue and waiting result JoinGroupRequest request = new JoinGroupRequest(GroupId, OperationCode, peer, arg); joinQueuing.Add(request); JoinGroupResponse result = await request.Task; joinHandling.Remove(request); // remove request from handling (because finished) if (result.type == JoinGroupResponse.ResultType.Accepted) { lock (peers) peers.Add(peer.Id, peer); peer.TrackGroup(this); try { if (OnPeerJoinedEvent != null) { OnPeerJoinedEvent.Invoke(peer); } } catch (Exception e) { debugger.LogError(e); } } return(result); }
private void LogError(object obj) { debugger.LogError(obj); }
public void LogError(object obj) { debugger.LogError(obj); }