コード例 #1
0
    private static void SendTestNetMessage()
    {
        SessionInterface sessionInterface = OnlineService.OnlineInterface?.SessionInterface;

        if (sessionInterface != null)
        {
            TestMessage msg = new TestMessage();

            msg.valueString = "test"; // 8 + 2
            msg.valueInt    = -10;    // 4
            msg.valueUInt   = 50;     // 4
            msg.valueShort  = -56;    // 2
            msg.valueUShort = 33;     // 2
            msg.valueBool   = true;   // 0.2
            msg.valueByte   = 12;     // 1
            msg.arrayOfInts = new int[] { 0, 1, 2 };
            msg.listOfInts  = new List <int> {
                0, 1, 2
            };


            msg.cat     = new TestMessageCat("FirstCat", 9);
            msg.dog     = new TestMessageDog("FirstDog", true);
            msg.animal  = new TestMessageDog("SurpriseDog!", false);
            msg.animals = new TestMessageAnimal[]
            {
                new TestMessageAnimal("Giraffe")
                , new TestMessageCat("Moustache", 99)
                , new TestMessageDog("Bento", true)
            };

            sessionInterface.SendNetMessage(msg, sessionInterface.Connections);
        }
    }
コード例 #2
0
            public DriverClient(SessionInterface sessionInterface)
            {
                _sessionInterface = sessionInterface;
                _sessionInterface.RegisterNetMessageReceiver <NetMessageSyncValue>(OnNetMessageReceived);
                _sessionInterface.RegisterNetMessageReceiver <NetMessageDestroyValue>(OnNetMessageReceived);
                _sessionInterface.RegisterNetMessageReceiver <NetMessageValueSyncComplete>(OnSyncComplete);

                _sessionInterface.SendNetMessage(new NetMessageRequestValueSync(), _sessionInterface.Connections);
            }
コード例 #3
0
            public DriverServer(SessionInterface sessionInterface)
            {
                _sessionInterface = sessionInterface;
                _sessionInterface.RegisterNetMessageReceiver <NetMessageRequestValueSync>(OnRequestValueSync);

                foreach (SyncedValueContainer container in SyncedValues.s_Containers)
                {
                    _sessionInterface.SendNetMessage(CreateSyncMessage(container), _sessionInterface.Connections);
                }
            }
コード例 #4
0
 internal void OnValueSetByUser(SyncedValueContainer container)
 {
     _sessionInterface.SendNetMessage(CreateSyncMessage(container), _sessionInterface.Connections);
 }