public int SendToPlayers(BaseRequest request) { SidekickSettings settings = BridgingContext.Instance.container.Settings; lastRequestID++; if (settings.InspectionConnection == InspectionConnection.LocalEditor) { if (ResponseReceived != null) { ResponseReceived(request.GenerateResponse()); } } else { byte[] bytes; using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { bw.Write(lastRequestID); bw.Write(request.GetType().Name); request.Write(bw); } bytes = ms.ToArray(); } #if SIDEKICK_DEBUG if (settings.LocalDevMode) { byte[] testResponse = SidekickRequestProcessor.Process(bytes); MessageEventArgs messageEvent = new MessageEventArgs(); messageEvent.data = testResponse; BaseResponse response = SidekickResponseProcessor.Process(testResponse); if (ResponseReceived != null) { ResponseReceived(response); } } else #endif { EditorConnection.instance.Send(RuntimeSidekickBridge.SEND_EDITOR_TO_PLAYER, bytes); } } return(lastRequestID); }
public int SendToPlayers(BaseRequest request) { lastRequestID++; if (commonContext.Settings.InspectionConnection == InspectionConnection.LocalEditor) { ResponseReceived(request.GenerateResponse()); } else { byte[] bytes; using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { bw.Write(lastRequestID); bw.Write(request.GetType().Name); request.Write(bw); } bytes = ms.ToArray(); } #if SIDEKICK_DEBUG if (commonContext.Settings.LocalDevMode) { byte[] testResponse = SidekickRequestProcessor.Process(bytes); MessageEventArgs messageEvent = new MessageEventArgs(); messageEvent.data = testResponse; BaseResponse response = SidekickResponseProcessor.Process(testResponse); ResponseReceived(response); } else #endif { EditorConnection.instance.Send(RuntimeSidekick.kMsgSendEditorToPlayer, bytes); } } return(lastRequestID); }
private void OnMessageEvent(MessageEventArgs args) { BaseResponse response = SidekickResponseProcessor.Process(args.data); APIManager.ResponseReceived(response); }
private void OnReceivedResponse(byte[] responseData) { BaseResponse response = SidekickResponseProcessor.Process(responseData); APIManager.ResponseReceived(response); }