public void StartGame(CS_StartGame cs, string connectionId) { try { SC_StartGame sc = new SC_StartGame() { Code = 1 }; var host = _host.Find(r => r.GameName == cs.GameName && r.ConnectionId == connectionId); if (host == null) { sc.Code = 105; sc.Msg = "StartGame Fail"; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } host.State = RoomState.Play; HubConnector.Client(connectionId).StartGame(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 105, Msg = "StartGame Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public void StartGame(object args) { CS_StartGame cs = JsonConvert.DeserializeObject <CS_StartGame>(args.ToString()); _host.StartGame(cs, Context.ConnectionId); }