private void OnClientReady(NetworkConnection arg1, ReadyMessage arg2)
 {
     //*Debug.Log("Client is ready to start: " + arg1);
     NetworkServer.SetClientReady(arg1);
     SpawnMoneyBags();
     //throw new NotImplementedException()
 }
Ejemplo n.º 2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 3
0
        public void ReadyMessageSetsClientReadyTest()
        {
            // listen
            NetworkServer.Listen(1);
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));

            // add connection
            ULocalConnectionToClient connection = new ULocalConnectionToClient();

            connection.connectionToServer = new ULocalConnectionToServer();
            NetworkServer.AddConnection(connection);

            // set as authenticated, otherwise readymessage is rejected
            connection.isAuthenticated = true;

            // serialize a ready message into an arraysegment
            ReadyMessage  message = new ReadyMessage();
            NetworkWriter writer  = new NetworkWriter();

            MessagePacker.Pack(message, writer);
            ArraySegment <byte> segment = writer.ToArraySegment();

            // call transport.OnDataReceived with the message
            // -> calls NetworkServer.OnClientReadyMessage
            //    -> calls SetClientReady(conn)
            Transport.activeTransport.OnServerDataReceived.Invoke(0, segment, 0);

            // ready?
            Assert.That(connection.isReady, Is.True);

            // shutdown
            NetworkServer.Shutdown();
        }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MessageType != global::Tron.Protocol.Wrappers.Server.ServerWrapperMessageType.WrappermessagetypeChat)
            {
                hash ^= MessageType.GetHashCode();
            }
            if (realMessageCase_ == RealMessageOneofCase.ChatMessage)
            {
                hash ^= ChatMessage.GetHashCode();
            }
            if (realMessageCase_ == RealMessageOneofCase.ReadyMessage)
            {
                hash ^= ReadyMessage.GetHashCode();
            }
            if (realMessageCase_ == RealMessageOneofCase.ConfigureMessage)
            {
                hash ^= ConfigureMessage.GetHashCode();
            }
            if (realMessageCase_ == RealMessageOneofCase.PlayerEventMessage)
            {
                hash ^= PlayerEventMessage.GetHashCode();
            }
            hash ^= (int)realMessageCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 private void ClientOnReady(object sender, ReadyMessage args)
 {
     //We have connected to the Discord IPC. We should send our rich presence just incase it lost it.
     Debug.Log("[DRP] Connection established and received READY from Discord IPC. Sending our previous Rich Presence and Subscription.");
     client.SetPresence((RichPresence)_currentPresence);
     client.SetSubscription(subscription.ToDiscordRPC());
 }
Ejemplo n.º 6
0
 /// <summary>
 ///   <para>Signal that the client connection is ready to enter the game.</para>
 /// </summary>
 /// <param name="conn">The client connection which is ready.</param>
 public static bool Ready(NetworkConnection conn)
 {
     if (ClientScene.s_IsReady)
     {
         if (LogFilter.logError)
         {
             Debug.LogError((object)"A connection has already been set as ready. There can only be one.");
         }
         return(false);
     }
     if (LogFilter.logDebug)
     {
         Debug.Log((object)("ClientScene::Ready() called with connection [" + (object)conn + "]"));
     }
     if (conn != null)
     {
         ReadyMessage readyMessage = new ReadyMessage();
         conn.Send((short)35, (MessageBase)readyMessage);
         ClientScene.s_IsReady                 = true;
         ClientScene.s_ReadyConnection         = conn;
         ClientScene.s_ReadyConnection.isReady = true;
         return(true);
     }
     if (LogFilter.logError)
     {
         Debug.LogError((object)"Ready() called with invalid connection object: conn=null");
     }
     return(false);
 }
Ejemplo n.º 7
0
    void OnReadyMessage(NetworkMessage msg)
    {
        ReadyMessage ready = msg.ReadMessage <ReadyMessage>();

        if (PongManager.instance.AuthUser(ready.user_id, ready.token))
        {
            Player player = findPlayer(msg.conn.connectionId);

            if (player != null)
            {
                player.user_id = ready.user_id;
                player.token   = ready.token;

                if (hostId == 0)
                {
                    hostId = player.connectionId;
                }
                else
                {
                    guestId = player.connectionId;
                }

                onPlayerJoined(player);

                PongMessage.SendStart(player.connectionId, hostId == player.connectionId);
            }
        }
    }
Ejemplo n.º 8
0
 private void OnReady(object sender, ReadyMessage args)
 {
     Debugger.Discord(
         GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_USER_CONNECTED']")
         .Replace("{Username}", args.User.ToString())
         );
 }
Ejemplo n.º 9
0
        private static async void Client_OnReady(object sender, ReadyMessage args)
        {
            var user = $"{args.User.Username}#{args.User.Discriminator:0000}";

            if (App.Config.LastUser != user)
            {
                App.Config.LastUser = user;
                await App.Config.Save();
            }

            App.Logging.LogEvent(App.Text.Client, $"{App.Text.Hi} {user} 👋");

            //Make update timer to update time in GUI
            _uptime = new Timer(new TimeSpan(0, 0, 1).TotalMilliseconds);
            if (Presence.Timestamps != null)
            {
                _uptime.Start();
            }

            _uptime.Elapsed += Uptime_Elapsed;

            MainPage._MainPage.Dispatcher.Invoke(() =>
            {
                MainPage._MainPage.rUsername.Text = user;
                MainPage._MainPage.rCon.Text      = App.Text.Connected;
            });
        }
        public static bool Ready(NetworkConnection conn)
        {
            if (s_IsReady)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("A connection has already been set as ready. There can only be one.");
                }
                return(false);
            }

            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
            }

            if (conn != null)
            {
                var msg = new ReadyMessage();
                conn.Send(MsgType.Ready, msg);
                s_IsReady                 = true;
                s_ReadyConnection         = conn;
                s_ReadyConnection.isReady = true;
                return(true);
            }
            if (LogFilter.logError)
            {
                Debug.LogError("Ready() called with invalid connection object: conn=null");
            }
            return(false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Sends a ready message to the distributor
        /// </summary>
        /// <param name="startup"></param>
        public void SendReadyMessage(bool startup)
        {
            if (DistributorControlAddress == null)
            {
                return;
            }

            if (!canSendReadyMessages)
            {
                return;
            }

            IMessage[] messages;
            if (startup)
            {
                messages = new IMessage[Transport.NumberOfWorkerThreads];
                for (var i = 0; i < Transport.NumberOfWorkerThreads; i++)
                {
                    var rm = new ReadyMessage
                    {
                        ClearPreviousFromThisAddress = (i == 0)
                    };

                    messages[i] = rm;
                }
            }
            else
            {
                messages    = new IMessage[1];
                messages[0] = new ReadyMessage();
            }

            Bus.Send(DistributorControlAddress, messages);
        }
Ejemplo n.º 12
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.READY:
            WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client;
            ReadyMessage         readyMessage   = (ReadyMessage)message;

            if (!qtRemoteClient.ready && readyMessage.state)
            {
                qtRemoteClient.ready = readyMessage.state;

                SessionMessage sessionMessage = new SessionMessage();
                sessionMessage.session = qtRemoteClient.session;
                qtRemoteClient.sendMessage(sessionMessage);

                QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Client(" + client.getIP() + ") is ready...");
                WorkerServerManager.instance.onClientReady(qtRemoteClient);
            }
            else
            {
                qtRemoteClient.ready = readyMessage.state;
            }
            break;
        }
    }
Ejemplo n.º 13
0
        private void _RpcClientOnReadyHandler(object sender, ReadyMessage args)
        {
            // send first presence
            _rpcClient.SetPresence(_gamePresenceToggle ? _gamePresence : _pagePresence);

            // enable updates timer
            _updateTimer.Enabled = true;
        }
Ejemplo n.º 14
0
        private static void OnReady(object sender, ReadyMessage args)
        {
            //This is called when we are all ready to start receiving and sending discord events.
            // It will give us some basic information about discord to use in the future.

            //It can be a good idea to send a inital presence update on this event too, just to setup the inital game state.
            Console.WriteLine("On Ready. RPC Version: {0}", args.Version);
        }
Ejemplo n.º 15
0
    public void ServerIsReady(NetworkMessage netMsg)
    {
        Debug.Log("Server is ready");
        ReadyMessage readyMsg = new ReadyMessage();

        readyMsg.isReady = m_isReady;
        NetworkServer.SendToAll(DataMsgType.READY_MSG, readyMsg);
    }
Ejemplo n.º 16
0
    //public void AAA(Item item) {
    //	NetworkClient.Send(new CraftingRequest {
    //		itemHashcode = item.GetHashCode()
    //	});
    //}

    #endregion

    #region Messages received from server

    private void AddPlayer(NetworkConnection connection, ReadyMessage message)
    {
        UIDMessage uidMessage = new UIDMessage {
            //uid = AuthenticationController.Instance.UID
            uid = "testUID"
        };

        ClientScene.AddPlayer(connection, MessagePacker.Pack(uidMessage));
    }
Ejemplo n.º 17
0
        public void ReadyMessage()
        {
            ReadyMessage message = new ReadyMessage();

            byte[] arr = MessagePackingTest.PackToByteArray(message);

            ReadyMessage fresh = MessagePackingTest.UnpackFromByteArray <ReadyMessage>(arr);

            Assert.That(fresh, Is.EqualTo(message));
        }
Ejemplo n.º 18
0
        public void ReadyMessageTest()
        {
            // try setting value with constructor
            ReadyMessage message = new ReadyMessage();

            byte[] arr = MessagePacker.Pack(message);
            Assert.DoesNotThrow(() => {
                ReadyMessage fresh = MessagePacker.Unpack <ReadyMessage>(arr);
            });
        }
 private void ReadyToSend(ReadyMessage ready)
 {
     if (udpVoiceHandler == null)
     {
         Logger.Info($"Connecting UDP VoIP");
         udpVoiceHandler = new UdpVoiceHandler(Guid, IPAddress.Loopback, port, gameState);
         udpVoiceHandler.Start();
         new Thread(SendAudio).Start();
     }
 }
Ejemplo n.º 20
0
        public void UnpackWrongMessage()
        {
            var message = new ReadyMessage();

            byte[] data = MessagePacker.Pack(message);

            Assert.Throws <FormatException>(() =>
            {
                _ = MessagePacker.Unpack <AddPlayerMessage>(data);
            });
        }
Ejemplo n.º 21
0
        public void UnpackWrongMessage()
        {
            SpawnMessage message = new SpawnMessage();

            byte[] data = PackToByteArray(message);

            Assert.Throws <FormatException>(() =>
            {
                ReadyMessage unpacked = UnpackFromByteArray <ReadyMessage>(data);
            });
        }
        private void HandleClientReady(object sender, ReadyMessage message)
        {
            RichPresenceUser = message.User;
            Log?.Invoke("Ready", "RPC", LogLevel.Info);
            Ready?.Invoke(message);

            if (_autoStart)
            {
                Start();
            }
        }
Ejemplo n.º 23
0
    public override void ServerChangeScene(string newSceneName)
    {
        m_isReady = false;

        base.ServerChangeScene(newSceneName);

        ReadyMessage readyMsg = new ReadyMessage();

        readyMsg.isReady = false;
        NetworkServer.SendToAll(DataMsgType.READY_MSG, readyMsg);
    }
Ejemplo n.º 24
0
        private void Handle(ReadyMessage message, string returnAddress)
        {
            Configurer.Logger.Info("Server available: " + returnAddress);

            if (message.ClearPreviousFromThisAddress) //indicates worker started up
            {
                WorkerAvailabilityManager.ClearAvailabilityForWorker(returnAddress);
            }

            WorkerAvailabilityManager.WorkerAvailable(returnAddress);
        }
Ejemplo n.º 25
0
        public void ReadyMessage()
        {
            // try setting value with constructor
            ReadyMessage message = new ReadyMessage();

            byte[] arr = MessagePackerTest.PackToByteArray(message);
            Assert.DoesNotThrow(() =>
            {
                ReadyMessage fresh = MessagePackerTest.UnpackFromByteArray <ReadyMessage>(arr);
            });
        }
Ejemplo n.º 26
0
    public override void OnServerSceneChanged(string sceneName)
    {
        base.OnServerSceneChanged(sceneName);

        Debug.Log("ServerSceneChanged");

        ReadyMessage readyMsg = new ReadyMessage();

        readyMsg.isReady = true;
        m_isReady        = true;
        NetworkServer.SendToAll(DataMsgType.READY_MSG, readyMsg);
    }
Ejemplo n.º 27
0
    public void UpdateReady(bool ready)
    {
        if (IsConnected())
        {
            // update local player.
            players[serverAssignedId].ready = ready;

            var readyMessage = new ReadyMessage();
            readyMessage.ready = ready;
            client.Send(CustomNetMsg.Ready, readyMessage);
        }
    }
Ejemplo n.º 28
0
        private void HandleMessage(IMessage message)
        {
            if (message == null)
            {
                return;
            }
            switch (message.Type)
            {
            //We got a update, so we will update our current presence
            case MessageType.PresenceUpdate:
                PresenceMessage pm = message as PresenceMessage;
                if (pm != null)
                {
                    //We need to merge these presences together
                    if (_presence == null)
                    {
                        _presence = pm.Presence;
                    }
                    else if (pm.Presence == null)
                    {
                        _presence = null;
                    }
                    else
                    {
                        _presence.Merge(pm.Presence);
                    }

                    //Update the message
                    pm.Presence = _presence;
                }

                break;

            //Update our configuration
            case MessageType.Ready:
                ReadyMessage rm = message as ReadyMessage;
                if (rm != null)
                {
                    _configuration = rm.Configuration;
                    _user          = rm.User;

                    //Resend our presence and subscription
                    SynchronizeState();
                }
                break;

            //We got a message we dont know what to do with.
            default:
                break;
            }
        }
    // Client messages
    public static void SendReady(string user_id, string token)
    {
        if (client == null)
        {
            return;
        }

        ReadyMessage msg = new ReadyMessage();

        msg.user_id = user_id;
        msg.token   = token;

        client.Send(PongMsgType.Ready, msg);
    }
Ejemplo n.º 30
0
        private void OnClientReady(object sender, ReadyMessage args)
        {
            UpdateTimer.Start();

            // start with constant values
            Client.SetPresence(new RichPresence
            {
                Timestamps = new Timestamps(StartTime),
                Assets     = new Assets
                {
                    LargeImageKey  = Constants.LargeImageKeyDnSpy,
                    LargeImageText = "dnSpy",
                },
            });
        }
Ejemplo n.º 31
0
 /// <summary>
 /// <para>Signal that the client connection is ready to enter the game.</para>
 /// </summary>
 /// <param name="conn">The client connection which is ready.</param>
 public static bool Ready(NetworkConnection conn)
 {
     if (s_IsReady)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("A connection has already been set as ready. There can only be one.");
         }
         return false;
     }
     if (LogFilter.logDebug)
     {
         Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
     }
     if (conn != null)
     {
         ReadyMessage msg = new ReadyMessage();
         conn.Send(0x23, msg);
         s_IsReady = true;
         s_ReadyConnection = conn;
         s_ReadyConnection.isReady = true;
         return true;
     }
     if (LogFilter.logError)
     {
         Debug.LogError("Ready() called with invalid connection object: conn=null");
     }
     return false;
 }
Ejemplo n.º 32
0
 /// <summary>
 ///   <para>Signal that the client connection is ready to enter the game.</para>
 /// </summary>
 /// <param name="conn">The client connection which is ready.</param>
 public static bool Ready(NetworkConnection conn)
 {
   if (ClientScene.s_IsReady)
   {
     if (LogFilter.logError)
       Debug.LogError((object) "A connection has already been set as ready. There can only be one.");
     return false;
   }
   if (LogFilter.logDebug)
     Debug.Log((object) ("ClientScene::Ready() called with connection [" + (object) conn + "]"));
   if (conn != null)
   {
     ReadyMessage readyMessage = new ReadyMessage();
     conn.Send((short) 35, (MessageBase) readyMessage);
     ClientScene.s_IsReady = true;
     ClientScene.s_ReadyConnection = conn;
     ClientScene.s_ReadyConnection.isReady = true;
     return true;
   }
   if (LogFilter.logError)
     Debug.LogError((object) "Ready() called with invalid connection object: conn=null");
   return false;
 }
Ejemplo n.º 33
0
    public static void setReady(string p1, string p2, string p3, string p4)
    {
        ReadyMessage message = new ReadyMessage();
        message.playerOneReady = p1;
        message.playerTwoReady = p2;
        message.playerThreeReady = p3;
        message.playerFourReady = p4;

        // Set info the display "READY" messages in MultiplayerLobbyScript
        playerReady[0] = p1;
        playerReady[1] = p2;
        playerReady[2] = p3;
        playerReady[3] = p4;

        readyQueue.Enqueue(message);
    }