• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NetworkMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NetworkMessage的典型用法代码示例。如果您正苦于以下问题:C# NetworkMessage类的具体用法?C# NetworkMessage怎么用?C# NetworkMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkMessage类属于命名空间,在下文中一共展示了NetworkMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ToNetworkMessage

 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromLocation);
     msg.AddByte(FromStackPosition);
     msg.AddLocation(ToLocation);
 }
开发者ID:Xileck,项目名称:tibiaapi,代码行数:7,代码来源:CreatureMovePacket.cs


示例2: ToNetworkMessage

 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddUInt32(CreatureId);
     msg.AddByte(LightLevel);
     msg.AddByte(LightColor);
 }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:7,代码来源:CreatureLightPacket.cs


示例3: AddMessageToSend

 public void AddMessageToSend(NetworkMessage mes)
 {
     lock (messageQueue)
     {
         messageQueue.Enqueue(mes);
     }
 }
开发者ID:kamiljano,项目名称:PCRemote,代码行数:7,代码来源:MouseController.xaml.cs


示例4: OnConnected

	void OnConnected(NetworkMessage msg)
	{
		Debug.Log (string.Format("Connected to Server"));
		connectionIdMessage connIdMsg = new connectionIdMessage ();
		connIdMsg.setConnId (client.connection.connectionId);
		client.Send(Message.GET_HAS_ROOM, connIdMsg);
	}
开发者ID:AE2GRP-CH,项目名称:game,代码行数:7,代码来源:MainMenu.cs


示例5: OnSetupGameOver

    public static void OnSetupGameOver(NetworkMessage netMsg)
    {
        var msg = netMsg.ReadMessage<PlayerMessage>();

        var gameOver = msg.player.GetComponent<PlayerRespawn>();
        gameOver.anim = GameObject.Find("HUDCanvas").GetComponent<Animator>();
    }
开发者ID:dshook,项目名称:chaos-king,代码行数:7,代码来源:GameSetup.cs


示例6: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            if (msg.GetByte() != (byte)OutgoingPacketType.AutoWalk)
                return false;

            Destination = destination;
            Type = OutgoingPacketType.AutoWalk;

            Directions = new List<Pokemon.Constants.Direction> { };
            byte count = msg.GetByte();

            for (int i = 0; i < count; i++)
            {
                Constants.Direction direction;
                byte dir = msg.GetByte();

                switch (dir)
                {
                    case 1: direction = Pokemon.Constants.Direction.Right; break;
                    case 2: direction = Pokemon.Constants.Direction.UpRight; break;
                    case 3: direction = Pokemon.Constants.Direction.Up; break;
                    case 4: direction = Pokemon.Constants.Direction.UpLeft; break;
                    case 5: direction = Pokemon.Constants.Direction.Left; break;
                    case 6: direction = Pokemon.Constants.Direction.DownLeft; break;
                    case 7: direction = Pokemon.Constants.Direction.Down; break;
                    case 8: direction = Pokemon.Constants.Direction.DownRight; break;
                    default: continue;
                }

                Directions.Add(direction);
            }

            return true;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:34,代码来源:AutoWalkPacket.cs


示例7: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            int position = msg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.ChannelOpen)
                return false;

            Destination = destination;
            Type = IncomingPacketType.ChannelOpen;

            ChannelId = (ChatChannel)msg.GetUInt16();
            ChannelName = msg.GetString();

            if (Client.VersionNumber >= 872)
            {
                NumberOfParticipants = msg.GetUInt16();
                for (ushort p = 0; p < NumberOfParticipants; p++)
                {
                    Participants[p] = msg.GetString();
                }
                NumberOfInvitees = msg.GetUInt16();
                for (ushort i = 0; i < NumberOfInvitees; i++)
                {
                    Invitees[i] = msg.GetString();
                }
            }

            return true;
        }
开发者ID:Xileck,项目名称:tibiaapi,代码行数:29,代码来源:ChannelOpenPacket.cs


示例8: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            int position = msg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.ContainerOpen)
                return false;

            Destination = destination;
            Type = IncomingPacketType.ContainerOpen;

            Id = msg.GetByte();
            ItemId = msg.GetUInt16();
            Name = msg.GetString();
            Capacity = msg.GetByte();
            HasParent = msg.GetByte();
            ItemCount = msg.GetByte();

            Items = new List<Tibia.Objects.Item>(ItemCount);

            for (int i = 0; i < ItemCount; i++)
            {
                Objects.Item item = msg.GetItem();
                item.Location = Tibia.Objects.ItemLocation.FromContainer(Id, (byte)i);
                Items.Add(item);
            }

            return true;
        }
开发者ID:Xileck,项目名称:tibiaapi,代码行数:28,代码来源:ContainerOpenPacket.cs


示例9: OnPlayerExperience

        public static void OnPlayerExperience(NetworkMessage netMsg)
        {
            var msg = netMsg.ReadMessage<PlayerExperienceMessage>();

            //Seems like the server is receiving the message as well
            FloatingTextManager.PlayerXp(msg.amount, msg.position);
        }
开发者ID:dshook,项目名称:chaos-king,代码行数:7,代码来源:PlayerLevel.cs


示例10: LogIn

    void LogIn(NetworkMessage netMsg, InfoMessage msg)
    {
        bool loggedIn = false;
        string query = "SELECT * FROM shogi.players WHERE players_email = \"" + msg.email + "\"";
        if (con.State.ToString () != "Open")
            con.Open ();

        using (con) {

            using (cmd = new MySqlCommand (query, con)) {
                rdr = cmd.ExecuteReader();
                if (rdr.HasRows) {
                    rdr.Read ();
                    if (msg.password == rdr["players_password"].ToString ()) {
                        incomeMessages.text += netMsg.conn.address + " logged in as " + msg.email + "\n";
                        loggedIn = true;
                    }
                    else
                        incomeMessages.text += netMsg.conn.address + " failed logging in for wrong password " + msg.password + "\n";
                }
                else
                    incomeMessages.text += netMsg.conn.address + " failed logging in for no entry " + msg.email + "\n";
                rdr.Dispose ();
            }

            string queryIP = "UPDATE shogi.players SET players_ip = \"" + netMsg.conn.address + "\" WHERE players_email = \"" + msg.email + "\"";
            if (loggedIn) {
                using (cmd = new MySqlCommand (queryIP, con))
                    cmd.ExecuteNonQuery ();
                msg.goal = "loggedin";
                NetworkServer.SendToClient(netMsg.conn.connectionId, MyMsgType.Info, msg);
            }
        }
    }
开发者ID:Fayanzar,项目名称:ShogiServer,代码行数:34,代码来源:InitNetwork.cs


示例11: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            int position = msg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.PlayerStatus)
                return false;

            Destination = destination;
            Type = IncomingPacketType.PlayerStatus;

            Health = msg.GetUInt16();
            MaxHealth = msg.GetUInt16();
            PokemonsCount = msg.GetUInt32();

            Experience = msg.GetUInt32();

            Level = msg.GetUInt16();

            LevelPercent = msg.GetByte();

            Pokemons = msg.GetUInt16();
            PokemonsMax = msg.GetUInt16();

            MagicLevel = msg.GetByte();
            MagicLevelPercent = msg.GetByte();
            Soul = msg.GetByte();

            Stamina = msg.GetUInt16();

            return true;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:31,代码来源:PlayerStatusPacket.cs


示例12: ToNetworkMessage

        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddUInt16(ChannelId);
            msg.AddString(Name);
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:7,代码来源:PrivateChannelCreatePacket.cs


示例13: ToNetworkMessage

 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddUInt32(PlayerId);
     msg.AddString(PlayerName);
     msg.AddByte(PlayerState);
 }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:7,代码来源:VipStatePacket.cs


示例14: ToNetworkMessage

        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddUInt16(Health);
            msg.AddUInt16(MaxHealth);
            msg.AddUInt32(Capacity);

            if (Client.VersionNumber >= 870)
            {
                msg.AddUInt64(Experience);
            }
            else
            {
                msg.AddUInt32((uint)Experience);
            }

            msg.AddUInt16(Level);

            msg.AddByte(LevelPercent);

            msg.AddUInt16(Mana);
            msg.AddUInt16(MaxMana);

            msg.AddByte(MagicLevel);
            msg.AddByte(MagicLevelPercent);
            msg.AddByte(Soul);

            msg.AddUInt16(Stamina);
        }
开发者ID:Xileck,项目名称:tibiaapi,代码行数:30,代码来源:PlayerStatusPacket.cs


示例15: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            int position = msg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.OutfitWindow)
                return false;

            Destination = destination;
            Type = IncomingPacketType.OutfitWindow;

            Default = msg.GetOutfit();

            byte count = msg.GetByte();
            OutfitList = new List<AvalibleOutfit> { };

            for (int i = 0; i < count; i++)
            {
                AvalibleOutfit outfit = new AvalibleOutfit();

                outfit.Id = msg.GetUInt16();
                outfit.Name = msg.GetString();
                outfit.Addons = msg.GetByte();

                OutfitList.Add(outfit);
            }

            return true;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:28,代码来源:OutfitWindowPacket.cs


示例16: Handle

    public static void Handle(NetworkMessage message)
    {
        switch (message.MessageType)
        {
            case NetworkMessageType.Connect:
                HandleConnect(message as ConnectMessage);
                break;
            case NetworkMessageType.StartGame:
                HandleStartGame(message as StartGameMessage);
                break;
            case NetworkMessageType.HitBall:
                HandleHitBall(message as HitBallMessage);
                break;
            case NetworkMessageType.CreateBall:
                HandleCreateBall(message as CreateBallMessage);
                break;
            case NetworkMessageType.LostBall:
                HandleLostBall(message as LostBallMessage);
                break;
            case NetworkMessageType.LevelUpBegin:
                HandleLevelUpBegin(message as LevelUpBeginMessage);
                break;
            case NetworkMessageType.LevelUpEnd:
                HandleLevelUpEnd(message as LevelUpEndMessage);
                break;
            case NetworkMessageType.EndGame:
                HandleEndGame(message as EndGameMessage);
                break;
            case NetworkMessageType.WaitForGame:
                HandleWaitForGame(message as WaitForGameMessage);
                break;

        }
    }
开发者ID:arahis,项目名称:Balls,代码行数:34,代码来源:MessageHandler.cs


示例17: ConnectReact

 void ConnectReact(NetworkMessage mes)
 {
     netController.client.UnregisterHandler (MsgType.Connect);
     netController.client.UnregisterHandler (MsgType.Disconnect);
     netController.client.UnregisterHandler (MsgType.Error);
     SceneManager.LoadScene ("game");
 }
开发者ID:VasiliyShevcheinko,项目名称:Unity3D_Balls,代码行数:7,代码来源:MenuBihavior.cs


示例18: Send

        public static void Send(NetworkMessage message, Action<byte[]> sendBytesMethod)
        {
            int headerSize = 8;
            byte[] messageCategoryBytes = UTF8Encoding.UTF8.GetBytes(message.MessageCategory);
            byte[] pipeBytes = UTF8Encoding.UTF8.GetBytes("|");
            byte[] messageTypeBytes = UTF8Encoding.UTF8.GetBytes(message.MessageType);
            byte[] messageSpaceBytes = UTF8Encoding.UTF8.GetBytes(" ");
            byte[] messageContentBytes = UTF8Encoding.UTF8.GetBytes(message.MessageContent);
            int length = messageContentBytes.Length + messageSpaceBytes.Length + messageTypeBytes.Length + pipeBytes.Length + messageCategoryBytes.Length;

            byte[] headerBytes = new byte[headerSize];
            headerBytes[0] = NetworkMessage.ProtocolHeader[0];
            headerBytes[1] = NetworkMessage.ProtocolHeader[1];
            headerBytes[2] = NetworkMessage.ProtocolMajorVersion;
            headerBytes[3] = NetworkMessage.ProtocolMinorVersion;
            for (int i = 7; i >= 4; i--)
            {
                headerBytes[i] = (byte)(length % 256);
                length /= 256;
            }

            sendBytesMethod(headerBytes);
            sendBytesMethod(messageCategoryBytes);
            sendBytesMethod(pipeBytes);
            sendBytesMethod(messageTypeBytes);
            sendBytesMethod(messageSpaceBytes);
            sendBytesMethod(messageContentBytes);
        }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:28,代码来源:ISocket.cs


示例19: OnCreateChannelResponse

	private void OnCreateChannelResponse(NetworkMessage netMsg)
	{
		Debug.Log ("OnCreateChannelResponse");

		var response_message = netMsg.ReadMessage<CreateChannelResponseMessage>();

		if(response_message.Created)
		{
			GameObject new_object = Instantiate (chat_content_prefab) as GameObject;
			Transform new_transform = new_object.transform;
			new_transform.SetParent (chat_window_transform, false);

			channel_transform_connections.Add (new ChannelTransformConnection() {
				ChannelId = response_message.ChannelId,
				ChatContentTransform = new_transform
			});

			channel_dropdown.AddOptions( new List<string>() {response_message.ChannelId});
			current_channel_id = response_message.ChannelId;
			channel_dropdown.value = channel_dropdown.options.Count-1; //select the new room

			send_button.interactable = true;
			input_text_field.interactable = true;

		}
	}
开发者ID:PlayFab,项目名称:PlayFabGameServer,代码行数:26,代码来源:ChatInterfaceLogic.cs


示例20: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            int msgPosition = msg.Position, outMsgPosition = outMsg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.FloorChangeUp)
                return false;

            Destination = destination;
            Type = IncomingPacketType.FloorChangeUp;
            outMsg.AddByte((byte)Type);

            Client.playerLocation.Z--;

            try
            {
                //going to surface
                if (Client.playerLocation.Z == 7)
                {
                    //floor 7 and 6 already set
                    for (int i = 5; i >= 0; i--)
                        ParseFloorDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, i, 18, 14, 8 - i, outMsg);
                }
                //underground, going one floor up (still underground)
                else if (Client.playerLocation.Z > 7)
                    ParseFloorDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, Client.playerLocation.Z - 2, 18, 14, 3, outMsg);

                return true;
            }
            finally
            {
                Client.playerLocation.X++;
                Client.playerLocation.Y++;
            }
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:34,代码来源:FloorChangeUpPacket.cs



注:本文中的NetworkMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetworkMode类代码示例发布时间:2022-05-24
下一篇:
C# NetworkManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap