public void onMatchJoined(string matchInfoJson) { Debug.Log("onMatchJoined,json:" + matchInfoJson); MatchInfo matchInfo = fromJson <MatchInfo>(matchInfoJson); if (listener != null) { listener.onMatchJoined(matchInfo); } }
private static void onCallBack(string eventName, string msg) { if (eventName == "onMatchJoined") { //do onMatchJoined Debug.Log("onMatchJoined,json:" + msg); MatchInfo matchInfo = JsonUtility.FromJson <MatchInfo>(msg); Debug.Log("listener is " + listener); if (listener != null) { listener.onMatchJoined(matchInfo); } } else if (eventName == "onMatchReadyToStart") { Debug.Log("onMatchReadyToStart"); MatchInfo matchInfo = JsonUtility.FromJson <MatchInfo>(msg); if (listener != null) { listener.onMatchReadyToStart(matchInfo); if (matchInfo.isNeedRecordScreen) { Debug.Log("start to record screen for this game"); timer = new Timer(); timer.Elapsed += delegate { var timestamp = ((DateTimeOffset)DateTime.UtcNow.ToLocalTime()).ToUnixTimeMilliseconds(); string picName = "screenshot-" + matchInfo.matchId + "-" + timestamp + ".jpeg"; TakeScreenshot(picName); }; //timer.Elapsed += new ElapsedEventHandler(TakeScreenshot); timer.Interval = 1000; timer.Enabled = true; } } } }