public GetBlockResult GetBlock(RPCConnection rpcConnection, int blockHeight) { var zend = new ZendRPC(); var res = zend.GetBlock(rpcConnection, blockHeight, 1); return(res); }
public GetInfoResult GetInfo(RPCConnection rpcConnection) { var zend = new ZendRPC(); var res = zend.GetInfo(rpcConnection); return(res); }
object OnCall(string typeName, string methodName, object thisObj, params object[] args) { if (typeName == "ConnectAPI" && methodName == "QueueGamePacket") { int packetID = (int)args[0]; IProtoBuf body = (IProtoBuf)args[1]; return(ConnectAPI_QueueGamePacket(packetID, body)); } if (typeName == "ConnectAPI" && methodName == "PacketReceived") { PegasusPacket p = (PegasusPacket)args[0]; Queue <PegasusPacket> state = (Queue <PegasusPacket>)args[1]; return(ConnectAPI_PacketReceived(p, state)); } else if (typeName == "bgs.RPCConnection" && methodName == "QueuePacket") { RPCConnection thiz = (RPCConnection)thisObj; BattleNetPacket packet = (BattleNetPacket)args[0]; return(RPCConnection_QueuePacket(thiz, packet)); } else if (typeName == "bgs.RPCConnection" && methodName == "PacketReceived") { RPCConnection thiz = (RPCConnection)thisObj; BattleNetPacket packet = (BattleNetPacket)args[0]; return(RPCConnection_PacketReceived(thiz, packet)); } return(null); }
public GetRawTransactionVerboseResult GetTransaction(RPCConnection rpcConnection, string transactionId) { var zend = new ZendRPC(); var res = zend.GetRawTransaction(rpcConnection, transactionId); return(res); }
public void ConnectToServer(string serverIP, Action <RPCConnection> Callback) { StartLoading(); if (string.IsNullOrEmpty(serverIP)) { serverIP = "127.0.0.1"; } if (!connectionListenersAdded) { _rpcConnection = new RPCConnection(serverIP, 2101); _rpcConnection.AddCallableObject(_notifications); _rpcConnection.OnConnect += rpcConnection_OnConnect; _rpcConnection.OnConnect += Callback; _rpcConnection.OnReconnect += rpcConnection_OnReconnect; _rpcConnection.OnError += rpcConnection_OnError; _rpcConnection.OnEnd += _rpcConnection_OnEnd; _rpcConnection.OnRetry += _rpcConnection_OnRetry; _rpcConnection.OnLog += _rpcConnection_OnLog; connectionListenersAdded = true; } _rpcConnection.Connect(); }
public async Task SearchForMessagesAsync(RPCConnection rpcConnection, int blockHeight) { this.blockHeight = blockHeight; var bd = GetBlock(rpcConnection, blockHeight); await SearchForMessagesAsync(rpcConnection, bd); }
public List <GetRawTransactionVerboseResult> GetTransactions(RPCConnection rpcConnection, List <string> txids) { var zend = new ZendRPC(); var res = zend.GetRawTransactions(rpcConnection, txids); return(res); }
public override void InitRPCListeners(RPCConnection rpcConnection) { base.InitRPCListeners(rpcConnection); rpcConnection.RegisterServiceMethodListener(this.m_friendsNotifyService.Id, 1, new RPCContextDelegate(this.NotifyFriendAddedListenerCallback)); rpcConnection.RegisterServiceMethodListener(this.m_friendsNotifyService.Id, 2, new RPCContextDelegate(this.NotifyFriendRemovedListenerCallback)); rpcConnection.RegisterServiceMethodListener(this.m_friendsNotifyService.Id, 3, new RPCContextDelegate(this.NotifyReceivedInvitationAddedCallback)); rpcConnection.RegisterServiceMethodListener(this.m_friendsNotifyService.Id, 4, new RPCContextDelegate(this.NotifyReceivedInvitationRemovedCallback)); }
void rpcConnection_OnError(RPCConnection connection, Exception ex) { DeviceManager.instance.ShowException(ex); if (ex.GetType() == typeof(SocketException) && ((SocketException)ex).ErrorCode == 11001) { _rpcConnection.Close(); } }
public override void InitRPCListeners(RPCConnection rpcConnection) { base.InitRPCListeners(rpcConnection); base.m_rpcConnection.RegisterServiceMethodListener(this.m_accountNotify.Id, 1, new RPCContextDelegate(this.HandleAccountNotify_AccountStateUpdated)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_accountNotify.Id, 2, new RPCContextDelegate(this.HandleAccountNotify_GameAccountStateUpdated)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_accountNotify.Id, 3, new RPCContextDelegate(this.HandleAccountNotify_GameAccountsUpdated)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_accountNotify.Id, 4, new RPCContextDelegate(this.HandleAccountNotify_GameSessionUpdated)); }
public override void InitRPCListeners(RPCConnection rpcConnection) { base.InitRPCListeners(rpcConnection); rpcConnection.RegisterServiceMethodListener(this.m_challengeNotifyService.Id, 1, new RPCContextDelegate(this.ChallengeUserCallback)); rpcConnection.RegisterServiceMethodListener(this.m_challengeNotifyService.Id, 2, new RPCContextDelegate(this.ChallengeResultCallback)); rpcConnection.RegisterServiceMethodListener(this.m_challengeNotifyService.Id, 3, new RPCContextDelegate(this.OnExternalChallengeCallback)); rpcConnection.RegisterServiceMethodListener(this.m_challengeNotifyService.Id, 4, new RPCContextDelegate(this.OnExternalChallengeResultCallback)); }
public override void InitRPCListeners(RPCConnection rpcConnection) { base.InitRPCListeners(rpcConnection); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 5, new RPCContextDelegate(this.HandleLogonCompleteRequest)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 10, new RPCContextDelegate(this.HandleLogonUpdateRequest)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 1, new RPCContextDelegate(this.HandleLoadModuleRequest)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 12, new RPCContextDelegate(this.HandleLogonQueueUpdate)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 13, new RPCContextDelegate(this.HandleLogonQueueEnd)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_authClientService.Id, 14, new RPCContextDelegate(this.HandleGameAccountSelected)); }
public bool CheckFilter(RPCConnection connection) { if (connection.currentServers.TryGetValue(server, out int?serverTribe)) { if (!serverTribe.HasValue) { return(true); //Is admin } return(serverTribe.Value == tribeId); } return(false); }
private object RPCConnection_PacketReceived(RPCConnection thisObj, BattleNetPacket packet) { using (StreamWriter sw = new StreamWriter("rpc_packets.txt", true)) { object body = packet.GetBody(); MethodDescriptor.ParseMethod parseMethod = null; string serviceDescriptor = ""; if (packet.GetHeader().ServiceId == 254) { RPCContext rPCContext; var waitingForResponse = typeof(RPCConnection).GetField("waitingForResponse", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(thisObj) as Dictionary <uint, RPCContext>; if (waitingForResponse.TryGetValue(packet.GetHeader().Token, out rPCContext)) { ServiceDescriptor importedServiceById = thisObj.serviceHelper.GetImportedServiceById(rPCContext.Header.ServiceId); if (importedServiceById != null) { parseMethod = importedServiceById.GetParser(rPCContext.Header.MethodId); body = parseMethod((byte[])body); } } } else { MethodInfo dynMethod = typeof(RPCConnection).GetMethod("GetExportedServiceDescriptor", BindingFlags.NonPublic | BindingFlags.Instance); ServiceDescriptor exportedServiceDescriptor = (ServiceDescriptor)dynMethod.Invoke(thisObj, new object[] { packet.GetHeader().ServiceId }); serviceDescriptor = exportedServiceDescriptor.ToString(); if (exportedServiceDescriptor != null) { parseMethod = thisObj.serviceHelper.GetExportedServiceById(packet.GetHeader().ServiceId).GetParser(packet.GetHeader().MethodId); // sw.WriteLine("parseMethod: " + parseMethod); if (parseMethod != null) { body = parseMethod((byte[])body); } } //ServiceDescriptor exportedServiceDescriptor = thisObj.GetExportedServiceDescriptor(); } sw.WriteLine("{\n" + " \"method\": \"RPCConnection.PacketReceived\",\n" + " \"serviceDescriptor\": \"" + serviceDescriptor + "\",\n" + " \"type\": \"" + body.ToString() + "\",\n" + " \"header\": " + JsonConvert.SerializeObject(packet.GetHeader(), Formatting.Indented).Replace("\n", "\n ") + ",\n" + " \"body\": " + JsonConvert.SerializeObject(body, Formatting.Indented).Replace("\n", "\n ") + ",\n" + " \"parseMethod\": " + (parseMethod != null ? "\"" + parseMethod.ToString() + "\"" : "null") + "\n" + "}"); } return(null); }
void rpcConnection_OnReconnect(RPCConnection rpcConnection) { Debug.LogWarning("Reconnecting..."); DeviceManager.instance.MainGame.GetGameDataAsync((gameData) => { Debug.Log("Fetching game data. Done!"); DeviceManager.instance.EndLoading(); GameData = gameData; }, (ex) => DeviceManager.instance.ShowException(ex)); serviceInterface.ReconnectServer(DeviceManager.instance._staffMemberID, DeviceManager.instance._staffPassword, rpcConnection); EndLoading(); }
private object RPCConnection_QueuePacket(RPCConnection thisObj, BattleNetPacket packet) { using (StreamWriter sw = new StreamWriter("rpc_packets.txt", true)) { sw.WriteLine("{\n" + " \"method\": \"RPCConnection.QueuePacket\",\n" + " \"type\": \"" + packet.GetBody().ToString() + "\",\n" + " \"header\": " + JsonConvert.SerializeObject(packet.GetHeader(), Formatting.Indented).Replace("\n", "\n ") + ",\n" + " \"body\": " + JsonConvert.SerializeObject(packet.GetBody(), Formatting.Indented).Replace("\n", "\n ") + "\n" + "}"); } return(null); }
public async Task HandleCommand(DeltaOpcodeWebSocketService baseConn) { RPCConnection conn = (RPCConnection)baseConn; //Create command JObject cmd = new JObject(); cmd["opcode"] = opcode; cmd["target_server"] = target_server?.ToString(); cmd["payload"] = payload; //Send await conn.SendMessage(RPCConnection.OUT_OPCODE_RPCMSG, cmd); }
public void SubAttractionReconnectServer(string subAttractionId, RPCConnection rpcConnection) { if (string.IsNullOrEmpty(subAttractionId)) { rpcConnection.RetryPendingCalls(); } else { AttractionDeviceManager.instance.MainGame.SubAttractionSessionReconnectedAsync(subAttractionId, () => { rpcConnection.RetryPendingCalls(); }, (ex) => AttractionDeviceManager.instance.ShowException(ex)); } }
public async Task SearchForMessagesAsync(RPCConnection rpcConnection, GetBlockResult bd) { this.blockHeight = bd.height; var transactions = Task.Run(() => GetTransactions(rpcConnection, bd.tx.ToList())); foreach (var tx in await transactions) { var res = ProcessTx(bd, tx); if (res == null || !res.Any()) { continue; } messages.AddRange(res); } }
void rpcConnection_OnReconnect(RPCConnection rpcConnection) { Debug.LogWarning("Reconnecting..."); if (AttractionDeviceManager.instance.CurrentDeviceType == DeviceType.Attraction) { Interface.AttractionReconnectServer(_attractionId, rpcConnection); } else if (AttractionDeviceManager.instance.CurrentDeviceType == DeviceType.SubAttraction) { Interface.SubAttractionReconnectServer(_subAttractionId, rpcConnection); } else if (AttractionDeviceManager.instance.CurrentDeviceType == DeviceType.Terminal) { Interface.SubAttractionGameTerminalReconnectServer(_attractionId, _subAttractionId, _terminalSubattractionId, rpcConnection); } }
//Callbacks void rpcConnection_OnConnect(RPCConnection RpcConnection) { Debug.Log("Connected..."); _isConnected = true; MainGame = new Juniverse.ClientLibrary.MainGame(RpcConnection); MainGame.OnProfileChanged += ProfileChangedNotification; MainGame.OnLoggedOut += LoggedOutNotification; _popUpManager.BindNotificationsFunctions(); Debug.Log("Fetching game data..."); DeviceManager.instance.MainGame.GetGameDataAsync((gameData) => { Debug.Log("Fetching game data. Done!"); DeviceManager.instance.EndLoading(); GameData = gameData; }, (ex) => DeviceManager.instance.ShowException(ex)); }
public void ConnectToServer(string serverIP) { if (string.IsNullOrEmpty(serverIP)) { serverIP = "127.0.0.1"; } _rpcConnection = new RPCConnection(serverIP, 2101); _rpcConnection.AddCallableObject(_notifications); _rpcConnection.OnConnect += rpcConnection_OnConnect; _rpcConnection.OnReconnect += rpcConnection_OnReconnect; _rpcConnection.OnError += rpcConnection_OnError; _rpcConnection.OnEnd += _rpcConnection_OnEnd; _rpcConnection.OnRetry += _rpcConnection_OnRetry; _rpcConnection.OnLog += _rpcConnection_OnLog; _rpcConnection.Connect(); }
void rpcConnection_OnConnect(RPCConnection RpcConnection) { Debug.Log("Connected..."); AttractionDeviceManager.instance.DeviceConnected = true; MainGame = new Juniverse.ClientLibrary.MainGame(RpcConnection); MainGame.OnLoggedOut += LoggedOutNoTification; DeviceNotificationManager.BindNotifications(); Debug.Log("Fetching game data..."); AttractionDeviceManager.instance.MainGame.GetGameDataAsync((gameData) => { Debug.Log("Fetching game data. Done!"); GameData = gameData; if (GameData.SubAttractions.ContainsKey(_subAttractionId)) { MultiPlayerGame = GameData.SubAttractions[_subAttractionId].MultiplayerGame; } if (ARGame) { if (CurrentARSession != null) { CacheCurrentSession(CurrentARSession.AttractionSessionId); AttractionDeviceManager.instance.SetCurrentSessionData(CurrentARSession.SubSessionId, CurrentARSession.PlayerId, CurrentARSession.ObjectiveId, CurrentARSession.AssignmentId, AttractionDeviceManager.instance.GameData.Quests[CurrentARSession.QuestId].Objectives.Find(x => x.Id == CurrentARSession.ObjectiveId)); } if (CurrentAutoTerminalSession != null) { CacheCurrentSession(CurrentAutoTerminalSession.AttractionSessionId); AttractionDeviceManager.instance.SetCurrentSessionData(CurrentAutoTerminalSession.SubSessionId, CurrentAutoTerminalSession.PlayerId, CurrentAutoTerminalSession.ObjectiveId, CurrentAutoTerminalSession.AssignmentId, AttractionDeviceManager.instance.GameData.Quests[CurrentAutoTerminalSession.QuestId].Objectives.Find(x => x.Id == CurrentAutoTerminalSession.ObjectiveId)); } } }, (ex) => AttractionDeviceManager.instance.ShowException(ex)); Debug.Log("rpcConnection_OnConnect"); StartTerminalSession(); }
void rpcConnection_OnError(RPCConnection connection, Exception ex) { AttractionDeviceManager.instance.ShowException(ex); }
void _rpcConnection_OnEnd(RPCConnection obj) { Debug.LogWarning("Connection end"); }
void _rpcConnection_OnRetry(RPCConnection obj) { Debug.LogWarning("Retrying connection"); }
void _rpcConnection_OnLog(RPCConnection arg1, string arg2) { Debug.Log(arg2); }
public bool CheckFilter(RPCConnection connection) { return(connection.currentServers.ContainsKey(server)); }
public bool CheckFilter(RPCConnection connection) { return(connection.currentUserId == user); }
public override void InitRPCListeners(RPCConnection rpcConnection) { base.InitRPCListeners(rpcConnection); base.m_rpcConnection.RegisterServiceMethodListener(this.m_gameUtilitiesService.Id, 6, new RPCContextDelegate(this.HandleGameUtilityServerRequest)); base.m_rpcConnection.RegisterServiceMethodListener(this.m_gameFactorySubscriberService.Id, 1, new RPCContextDelegate(this.HandleNotifyGameFoundRequest)); }