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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 5
0
    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));
 }
Ejemplo n.º 9
0
 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));
 }
Ejemplo n.º 11
0
 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));
 }
Ejemplo n.º 13
0
 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);
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
    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();
    }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
 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);
            }
        }
Ejemplo n.º 20
0
 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);
     }
 }
Ejemplo n.º 21
0
 //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));
 }
Ejemplo n.º 22
0
        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();
        }
Ejemplo n.º 23
0
        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();
        }
Ejemplo n.º 24
0
 void rpcConnection_OnError(RPCConnection connection, Exception ex)
 {
     AttractionDeviceManager.instance.ShowException(ex);
 }
Ejemplo n.º 25
0
 void _rpcConnection_OnEnd(RPCConnection obj)
 {
     Debug.LogWarning("Connection end");
 }
Ejemplo n.º 26
0
 void _rpcConnection_OnRetry(RPCConnection obj)
 {
     Debug.LogWarning("Retrying connection");
 }
Ejemplo n.º 27
0
 void _rpcConnection_OnLog(RPCConnection arg1, string arg2)
 {
     Debug.Log(arg2);
 }
Ejemplo n.º 28
0
 public bool CheckFilter(RPCConnection connection)
 {
     return(connection.currentServers.ContainsKey(server));
 }
Ejemplo n.º 29
0
 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));
 }