예제 #1
0
    static public void NoAccount()
    {
        NetworkWriter wr = new NetworkWriter();

        wr.StartMessage(Networking_msgType_Sr.NoAccount);
        wr.Write(0);
        wr.FinishMessage();
        tempConn.SendWriter(wr, 0);
        tempConn = null;
    }
        // Token: 0x06001EE6 RID: 7910 RVA: 0x00085E34 File Offset: 0x00084034
        private void ReleasePredictionId(NetworkConnection owner, ushort predictionId)
        {
            this.releasePredictionIdMsg.predictionId = predictionId;
            NetworkWriter networkWriter = new NetworkWriter();

            networkWriter.StartMessage(50);
            networkWriter.Write(this.releasePredictionIdMsg);
            networkWriter.FinishMessage();
            owner.SendWriter(networkWriter, 0);
        }
예제 #3
0
    public void SentMessage(string message)
    {
        short myMsgType = 444;

        NetworkWriter writer = new NetworkWriter();

        writer.StartMessage(myMsgType);
        writer.Write("message");
        writer.FinishMessage();
    }
예제 #4
0
        /// Send the server a message indicating which player the client has chosen.
        public override void OnClientConnect(NetworkConnection conn)
        {
            base.OnClientConnect(conn);

            clientConnectionToServer = conn;

            // Set the character
            var writer = new NetworkWriter();

            writer.StartMessage(NetworkMessages.SetPlayerName);
            writer.Write(TransitionParams.playerName);
            writer.FinishMessage();
            conn.SendWriter(writer, 0);

            // Set the display name
            if (TransitionParams.displayName != null)
            {
                writer.StartMessage(NetworkMessages.SetPlayerDisplayName);
                writer.Write(TransitionParams.displayName);
                writer.FinishMessage();
                conn.SendWriter(writer, 0);
            }

            if (TransitionParams.team != -1)
            {
                writer.StartMessage(NetworkMessages.SetPlayerTeam);
                writer.Write(TransitionParams.team);
                writer.FinishMessage();
                conn.SendWriter(writer, 0);
            }

            if (TransitionParams.leaderboardId != -1)
            {
                writer.StartMessage(NetworkMessages.SetPlayerLeaderboardId);
                writer.Write(TransitionParams.leaderboardId);
                writer.FinishMessage();
                NetworkController.clientConnectionToServer.SendWriter(writer, 0);
            }

            this.client.connection.RegisterHandler(NetworkMessages.SyncClock, ClientSyncClock);
            StartCoroutine(SyncClockCoroutine(conn));
        }
예제 #5
0
        [ServerCallback] // @ server
        public void ForwardAvatarPose(NetworkMessage msg)
        {
            short         msgType = MsgType.Highest + 2;
            NetworkWriter sWriter = new NetworkWriter();

            sWriter.StartMessage(msgType);
            ForwardAvatarPose(msg.reader, sWriter);
            sWriter.FinishMessage();

            NetworkServer.SendWriterToReady(null, sWriter, Channels.DefaultUnreliable);
        }
예제 #6
0
    void SendMessage()
    {
        NetworkWriter writer = new NetworkWriter();

        writer.StartMessage(k_myMsg);
        writer.Write(42);
        writer.Write("Are you ok?");
        writer.FinishMessage();

        client.SendWriter(writer, 0);
    }
    //Zombie start attack and block move
    public void ZombieAttack()
    {
        attack = true;
        NetworkWriter wr = new NetworkWriter();

        wr.StartMessage(Networking_msgType_Sr.ZombieAttack);
        wr.Write(index);
        wr.FinishMessage();
        RoomsManager.SendReliableAtRoom(wr, index);
        Invoke("ZombieAttackDone", 1.8f);
    }
    public static void SendMyAction(short msgType)
    {
        NetworkWriter wr = new NetworkWriter();

        wr.StartMessage(msgType);
        wr.Write(Data_MyData.sessionID);
        wr.Write(Data_MyData.Login);
        wr.Write(Data_MyData.Password);
        wr.FinishMessage();
        net.SendWriter(wr, 1);
    }
예제 #9
0
    void SyncPosition()
    {
        NetworkWriter wr = new NetworkWriter();

        wr.StartMessage(Networking_msgType_Sr.ItemPositionUpdate);
        wr.Write(index);
        wr.Write(transform.position);
        wr.Write(transform.rotation);
        wr.FinishMessage();
        RoomsManager.SendUnreliableToRoom(wr, roomID);
        Invoke("SyncPosition", syncTime);
    }
예제 #10
0
        virtual public void SendAvatarPose2Server(NetworkIdentity identity, HumanoidControl humanoid)
        {
            short msgType = MsgType.Highest + 1;

            writer = new NetworkWriter();

            writer.StartMessage(msgType);
            this.SendAvatarPose(humanoid);
            writer.FinishMessage();

            identity.connectionToServer.SendWriter(writer, Channels.DefaultUnreliable);
        }
예제 #11
0
        private IEnumerator SendDelay(int id, Vector2 input)
        {
            yield return(new WaitForSeconds(sendDelay));

            writer.StartMessage(MovementInputServer.MSG_ID);
            writer.Write(netId);
            writer.Write(input);
            writer.Write(id);
            writer.FinishMessage();

            ClientScene.readyConnection.SendWriter(writer, Channels.DefaultUnreliable);
        }
예제 #12
0
        IEnumerator SyncClockCoroutine(NetworkConnection conn)
        {
            var writer = new NetworkWriter();

            for (int i = 0; i < 5; i++)
            {
                writer.StartMessage(NetworkMessages.SyncClock);
                writer.Write(Time.realtimeSinceStartup);
                writer.FinishMessage();
                conn.SendWriter(writer, 1);
                yield return(new WaitForSeconds(.5f));
            }
        }
예제 #13
0
파일: Hmd.cs 프로젝트: RogerFK/HMD
        private static void TargetShake(GameObject target)
        {
            int rpcId = -737840022;

            NetworkWriter writer = new NetworkWriter();

            writer.Write((short)0);
            writer.Write((short)2);
            writer.WritePackedUInt32((uint)rpcId);
            writer.Write(target.GetComponent <NetworkIdentity>().netId);
            writer.FinishMessage();
            target.GetComponent <CharacterClassManager>().connectionToClient.SendWriter(writer, 0);
        }
예제 #14
0
    /// <summary>
    /// Send int value by reliable channel 0
    /// </summary>
    /// <param name="msgType"></param>
    /// <param name="value"></param>
    /// <param name="sessionID"></param>
    public static void SendInt(short msgType, int value, int sessionID)
    {
        NetworkConnection conn = GetPlayerConnection(sessionID);

        if (conn != null)
        {
            NetworkWriter wr = new NetworkWriter();
            wr.StartMessage(msgType);
            wr.Write(value);
            wr.FinishMessage();
            conn.SendWriter(wr, 0);
        }
    }
예제 #15
0
        /// <summary>
        /// Forces the Peer to disconnect, raising the OnDisconnect event in the process.
        /// This method is also called when a peer disconnects or loses connection normally.
        /// </summary>
        public void DisconnectWithMessage(byte disconnectMsgIdentifier)
        {
            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(ScopeMsgType.DisconnectMessage);
            writer.Write(disconnectMsgIdentifier);
            writer.FinishMessage();

            ScopeUtils.SendNetworkWriter(writer, this);

            // trigger early disconnection
            ForceDisconnect(false);
        }
예제 #16
0
        public static void SendScopeExitedMessage <TPeer>(BaseServerScope <TPeer> scope, NetworkConnection connection) where TPeer : NetworkPeer
        {
            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(ScopeMsgType.ExitScope);

            // 1. msgType: Determines which channel to communicate on
            writer.Write(scope.msgType);

            writer.FinishMessage();

            SendNetworkWriter(writer, connection);
        }
예제 #17
0
 private void SendTransform()
 {
     if (HasMoved() && ClientScene.readyConnection != null)
     {
         m_LocalTransformWriter.StartMessage(16);
         m_LocalTransformWriter.Write(base.netId);
         m_LocalTransformWriter.WritePackedUInt32(m_ChildIndex);
         SerializeModeTransform(m_LocalTransformWriter);
         m_PrevPosition = m_Target.localPosition;
         m_PrevRotation = m_Target.localRotation;
         m_LocalTransformWriter.FinishMessage();
         ClientScene.readyConnection.SendWriter(m_LocalTransformWriter, GetNetworkChannel());
     }
 }
예제 #18
0
        /// <summary>
        /// Sends instructions to reconnect to the specified host.
        /// </summary>
        /// <param name="hostname">IP Address or Host.</param>
        /// <param name="port">Server port.</param>
        public void Redirect(string hostname, int port)
        {
            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(ScopeMsgType.RedirectMessage);
            writer.Write(hostname);
            writer.Write(port);
            writer.FinishMessage();

            ScopeUtils.SendNetworkWriter(writer, this);

            // trigger early disconnection
            ForceDisconnect(false);
        }
예제 #19
0
        public void SendUpdate()
        {
            if (writer == null)
            {
                writer = new NetworkWriter();
            }

            writer.StartMessage(MovementInputServer.MSG_ID);
            writer.Write((Vector2)transform.position);
            writer.Write(input.LatestInputID);
            writer.FinishMessage();

            NetworkServer.SendWriterToReady(gameObject, writer, 0);
        }
예제 #20
0
        //public static void SendBitstreamToAllClients(ref UdpBitStream bitstream, short msgType, int channel = Channels.DefaultUnreliable)
        //{
        //	reusablewriter.StartMessage(msgType);
        //	reusablewriter.WriteUncountedByteArray(bitstream.Data, bitstream.BytesUsed);
        //	reusablewriter.FinishMessage();
        //	//reusablewriter.SendPayloadArrayToAllClients(msgType);

        //	foreach (NetworkConnection nc in NetworkServer.connections)
        //	{
        //		if (nc == null)
        //			continue;

        //		nc.SendWriter(reusablewriter, channel);
        //	}
        //}

        public static void SendPayloadArrayToAllClients(this NetworkWriter writer, short msgType, int channel = Channels.DefaultUnreliable)
        {
            reusablewriter.StartMessage(msgType);

            byte[] writerArray = writer.AsArray();
            int    count       = writer.Position;

            for (int i = 4; i < count; ++i)
            {
                reusablewriter.Write(writerArray[i]);
            }
            reusablewriter.FinishMessage();

            foreach (NetworkConnection nc in NetworkServer.connections)
            {
                if (nc == null)
                {
                    continue;
                }

                nc.SendWriter(reusablewriter, channel);
            }
        }
예제 #21
0
 // Token: 0x060013A3 RID: 5027 RVA: 0x00053DA4 File Offset: 0x00051FA4
 public void ResetSkills()
 {
     if (NetworkServer.active && this.networkIdentity.clientAuthorityOwner != null)
     {
         NetworkWriter networkWriter = new NetworkWriter();
         networkWriter.StartMessage(56);
         networkWriter.Write(base.gameObject);
         networkWriter.FinishMessage();
         this.networkIdentity.clientAuthorityOwner.SendWriter(networkWriter, QosChannelIndex.defaultReliable.intVal);
     }
     for (int i = 0; i < this.allSkills.Length; i++)
     {
         this.allSkills[i].Reset();
     }
 }
예제 #22
0
    public void SendMessage(string targetObjectName, string methodName, object param, object param2, object param3, object param4, object param5, object param6, object param7, object param8, object param9, object param10, object param11, object param12, object param13, object param14, object param15, object param16, MsgType msgType = MsgType.Reliable)
    {
        if (debugRPC)
        {
            LogUI("CAVE2 SendMessage (Param 18)'" + methodName + "' on " + targetObjectName);
        }

        NetworkWriter writer = new NetworkWriter();

        writer.StartMessage(216);
        writer.Write(targetObjectName);
        writer.Write(methodName);
        writer.Write(16);

        ParamToByte(writer, param);
        ParamToByte(writer, param2);
        ParamToByte(writer, param3);
        ParamToByte(writer, param4);
        ParamToByte(writer, param5);
        ParamToByte(writer, param6);
        ParamToByte(writer, param7);
        ParamToByte(writer, param8);
        ParamToByte(writer, param9);
        ParamToByte(writer, param10);
        ParamToByte(writer, param11);
        ParamToByte(writer, param12);
        ParamToByte(writer, param13);
        ParamToByte(writer, param14);
        ParamToByte(writer, param15);
        ParamToByte(writer, param16);

        writer.FinishMessage();

        ServerSendMsgToClients(writer.ToArray(), msgType);

#if USING_GETREAL3D
        if (getReal3D.Cluster.isMaster)
        {
            getReal3D.RpcManager.call("SendCAVE2RPC18", targetObjectName, methodName, param, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16);
        }
        else
        {
            SendCAVE2RPC18(targetObjectName, methodName, param, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16);
        }
#else
        SendCAVE2RPC18(targetObjectName, methodName, param, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16);
#endif
    }
예제 #23
0
        // Token: 0x06000A57 RID: 2647 RVA: 0x00033C0C File Offset: 0x00031E0C
        public static void SendBroadcastChat(Chat.ChatMessageBase message, int channelIndex)
        {
            NetworkWriter networkWriter = new NetworkWriter();

            networkWriter.StartMessage(59);
            networkWriter.Write(message.GetTypeIndex());
            networkWriter.Write(message);
            networkWriter.FinishMessage();
            foreach (NetworkConnection networkConnection in NetworkServer.connections)
            {
                if (networkConnection != null)
                {
                    networkConnection.SendWriter(networkWriter, channelIndex);
                }
            }
        }
예제 #24
0
        public static void SendScopeEnteredMessage <TPeer>(BaseServerScope <TPeer> scope, NetworkConnection connection) where TPeer : NetworkPeer
        {
            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(ScopeMsgType.EnterScope);

            // 1. scopeIdentifier: The value which identifier the counterpart client class
            writer.Write(scope.msgType);

            // 2. msgType: Determines which channel to communicate on
            writer.Write(scope.scopeIdentifier);

            writer.FinishMessage();

            SendNetworkWriter(writer, connection);
        }
예제 #25
0
        /// <summary>
        /// Method serializes message and sends it to server.
        /// </summary>
        /// <param name="msgType">Type of message. This specifies
        /// the type of the payload. This is important in
        /// networked scenarios, when proper deseriaization into
        /// the correct type requires knowing what was
        /// used to serialize the object originally.
        /// </param>
        /// <param name="msg">The message to send.
        /// This utilises UNET's MessageBase so it is
        /// Auto [de]serialized by UNET.
        /// This also allows us to send messages that are not
        /// part of Mercury XM</param>
        public virtual void MmSendMessageToServer(short msgType, MessageBase msg)
        {
            if (MmNetworkManager.Instance.NetworkClient == null)
            {
                MmLogger.LogFramework("No client present on host");
                return;
            }

            NetworkWriter writer = new NetworkWriter();

            writer.StartMessage(msgType);
            msg.Serialize(writer);
            writer.FinishMessage();

            MmNetworkManager.Instance.NetworkClient.SendWriter(writer, Channels.DefaultReliable);
        }
예제 #26
0
 void Send(MessageType type)
 {
     if (!MessageActive(type))
     {
         return;
     }
     writer.StartMessage(NetworkMessages.StateChangeBroadcast);
     writer.Write((byte)type);
     writer.FinishMessage();
     SendWriter();
 }
예제 #27
0
        public void Send(NetworkConnection recipient, Func <string> dataSendType = null)
        {
            if (!finished)
            {
                writer.FinishMessage();
                finished = true;
            }

            if (dataSendType == null)
            {
                socket.SendData(recipient, channelID, writer.ToArray(), writer.Position, null);
            }
            else
            {
                socket.SendData(recipient, channelID, writer.ToArray(), writer.Position, dataSendType);
            }
        }
예제 #28
0
 public void SendInput(string name, Vector2[] points)
 {
     if (connected)
     {
         NetworkWriter writer = new NetworkWriter();
         writer.StartMessage(NetMsgId.inputGesture);
         writer.Write(name);
         int length = points.Length;
         writer.Write(length);
         for (int a = 0; a < length; a++)
         {
             writer.Write(points [a]);
         }
         writer.FinishMessage();
         cli.SendWriter(writer, 0);
     }
 }
예제 #29
0
    void ServerSendMsgToClients(string msgStr)
    {
        System.Collections.ObjectModel.ReadOnlyCollection <NetworkConnection> connections = msgServer.connections;

        foreach (NetworkConnection client in connections)
        {
            if (client != null)
            {
                NetworkWriter writer = new NetworkWriter();
                writer.StartMessage(MessageID);
                writer.Write(msgStr);
                writer.FinishMessage();
                Debug.Log("sending: " + msgStr);
                msgServer.SendWriterTo(client.connectionId, writer, 0);
            }
        }
    }
    void SendTransform()
    {
        if (!HasMoved() || ClientScene.readyConnection == null)
        {
            return;
        }

        m_LocalNetworkWriter.StartMessage(MsgType.LocalPlayerTransform);
        m_LocalNetworkWriter.Write(netId);

        m_LocalNetworkWriter.Write(transform.position);
        m_PreviousPosition = transform.position;

        m_LocalNetworkWriter.FinishMessage();

        ClientScene.readyConnection.SendWriter(m_LocalNetworkWriter, GetNetworkChannel());
    }