void OnBroadcastJoin(NotificationArg arg) { BroadcastJoin data = arg.GetValue <BroadcastJoin>(); var p = CreatePlayer(data.x, data.y, data.playerID, data.type); players.Add(data.playerID, p); }
public override void FromData(byte[] data) { var jsonString = System.Text.Encoding.Default.GetString(data); BroadcastJoin jsonData = JsonUtility.FromJson <BroadcastJoin>(jsonString); this.playerID = jsonData.playerID; this.name = jsonData.name; this.x = jsonData.x; this.y = jsonData.y; this.type = jsonData.type; }
private void HandleMessage(Message msg) { var msgID = (MsgID)msg.MessageID; switch (msgID) { case MsgID.Response_Join: { ResponseJoin data = new ResponseJoin(); data.FromMessage(msg); NotificationCenter.Instance.PushEvent(NotificationType.Network_OnResponseJoin, data); break; } case MsgID.Broadcast_Move: { BroadcastMove data = new BroadcastMove(); data.FromMessage(msg); NotificationCenter.Instance.PushEvent(NotificationType.Network_OnBroadcastMove, data); break; } case MsgID.Broadcast_Join: { BroadcastJoin data = new BroadcastJoin(); data.FromMessage(msg); NotificationCenter.Instance.PushEvent(NotificationType.Network_OnBroadcastJoin, data); break; } case MsgID.Broadcast_Leave: { BroadcastLeave data = new BroadcastLeave(); data.FromMessage(msg); NotificationCenter.Instance.PushEvent(NotificationType.Network_OnBroadcastLeave, data); break; } } }