Esempio n. 1
0
        public void Connect(string obj)
        {
            MelonLogger.Log("Starting client and connecting");

            ServerId = ulong.Parse(obj);
            MelonLogger.Log("Connecting to " + obj);

            P2PMessage msg = new P2PMessage();

            msg.WriteByte((byte)MessageType.Join);
            msg.WriteByte(MultiplayerMod.PROTOCOL_VERSION);
            msg.WriteUnicodeString(SteamClient.Name);

            connection = transportLayer.ConnectTo(ServerId, msg);
            transportLayer.OnConnectionClosed += TransportLayer_OnConnectionClosed;
            transportLayer.OnMessageReceived  += TransportLayer_OnMessageReceived;

            isConnected        = true;
            localRigTransforms = BWUtil.GetLocalRigTransforms();

            ui.SetState(MultiplayerUIState.Client);
            GunHooks.OnGunFire                += BWUtil_OnFire;
            PlayerHooks.OnPlayerGrabObject    += PlayerHooks_OnPlayerGrabObject;
            PlayerHooks.OnPlayerReleaseObject += PlayerHooks_OnPlayerReleaseObject;

            MultiplayerMod.OnLevelWasLoadedEvent += MultiplayerMod_OnLevelWasLoadedEvent;
        }
Esempio n. 2
0
        public void Connect(string obj)
        {
            MelonModLogger.Log("Starting client and connecting");

            ServerId = ulong.Parse(obj);
            MelonModLogger.Log("Connecting to " + obj);

            P2PMessage msg = new P2PMessage();

            msg.WriteByte((byte)MessageType.Join);
            msg.WriteByte(MultiplayerMod.PROTOCOL_VERSION);
            msg.WriteUnicodeString(SteamClient.Name);

            connection = transportLayer.ConnectTo(ServerId, msg);
            transportLayer.OnConnectionClosed += TransportLayer_OnConnectionClosed;
            transportLayer.OnMessageReceived  += TransportLayer_OnMessageReceived;
            //SteamNetworking.SendP2PPacket(ServerId, msg.GetBytes());

            isConnected = true;
            //PlayerHooks.OnPlayerGrabObject += PlayerHooks_OnPlayerGrabObject;
            //PlayerHooks.OnPlayerLetGoObject += PlayerHooks_OnPlayerLetGoObject;
            localRigTransforms = BWUtil.GetLocalRigTransforms();

            //SteamNetworking.OnP2PSessionRequest = OnP2PSessionRequest;
            //SteamNetworking.OnP2PConnectionFailed = OnP2PConnectionFailed;
            ui.SetState(MultiplayerUIState.Client);
        }
Esempio n. 3
0
        public void TestStringMessageRoundTrip()
        {
            P2PMessage msg = new P2PMessage();

            msg.WriteUnicodeString("hello world!");

            byte[] msgBytes = msg.GetBytes();

            P2PMessage readMsg = new P2PMessage(msgBytes);

            Assert.AreEqual(readMsg.ReadUnicodeString(), "hello world!");
        }
Esempio n. 4
0
        public void TestMultipleRoundTrip()
        {
            P2PMessage msg = new P2PMessage();

            msg.WriteByte(172);
            msg.WriteUnicodeString("hello world! Зарегистрируйтесь ⡌⠁⠧⠑ ⠼⠁⠒  ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌");
            msg.WriteFloat(1412.2f);

            byte[] msgBytes = msg.GetBytes();

            P2PMessage readMsg = new P2PMessage(msgBytes);

            Assert.AreEqual(readMsg.ReadByte(), 172);
            Assert.AreEqual(readMsg.ReadUnicodeString(), "hello world! Зарегистрируйтесь ⡌⠁⠧⠑ ⠼⠁⠒  ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌");
            Assert.AreEqual(readMsg.ReadFloat(), 1412.2f, TEST_MARGIN);
        }
Esempio n. 5
0
        public void Connect(string obj)
        {
            MelonModLogger.Log("Starting client and connecting");

            ServerId = ulong.Parse(obj);
            MelonModLogger.Log("Connecting to " + obj);

            P2PMessage msg = new P2PMessage();

            msg.WriteByte((byte)MessageType.Join);
            msg.WriteByte(JobSimulatorMultiplayer.PROTOCOL_VERSION);
            msg.WriteUnicodeString(SteamClient.Name);
            SteamNetworking.SendP2PPacket(ServerId, msg.GetBytes());

            isConnected = true;
            JobSimulatorMultiplayer.isClient = true;

            SteamNetworking.OnP2PSessionRequest   = OnP2PSessionRequest;
            SteamNetworking.OnP2PConnectionFailed = OnP2PConnectionFailed;

            MelonCoroutines.Start(PhysicSyncLoad());
        }