当前位置: 首页>>代码示例>>C#>>正文


C# NetConnection.SendMessage方法代码示例

本文整理汇总了C#中Lidgren.Network.NetConnection.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# NetConnection.SendMessage方法的具体用法?C# NetConnection.SendMessage怎么用?C# NetConnection.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lidgren.Network.NetConnection的用法示例。


在下文中一共展示了NetConnection.SendMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorldDataSync

        public WorldDataSync(NetConnection Connection)
        {
            Connect = Connection;

            NetOutgoingMessage Message = NetworkManager.Server.CreateMessage();
            Message.Write((byte)MessageTypes.ConnectionOkay);
            Connection.SendMessage(Message, NetDeliveryMethod.ReliableUnordered, 0);

            NetOutgoingMessage NameRequest = NetworkManager.Server.CreateMessage();
            NameRequest.Write((byte)MessageTypes.RequestPlayerName);
            Connection.SendMessage(NameRequest, NetDeliveryMethod.ReliableUnordered, 0);
        }
开发者ID:fusspawn,项目名称:sobriety,代码行数:12,代码来源:WorldDataInit.cs

示例2: Authenticate

        /// <summary>
        /// Authenticates the connection
        /// </summary>
        /// <param name="connection">Connection to authenticate</param>
        /// <param name="username">Username</param>
        /// <param name="password">Password</param>
        /// <param name="data">Additional data to send</param>
        public static void Authenticate(NetConnection connection, String username, String password, Byte[] data = null)
        {
            var handshake = new Handshake(true, KeySize);
            var request = handshake.GenerateSRPRequest(username, password, data ?? new Byte[0]);

            var result = Create(connection, Handshake.Contents.Username, request.ByteSize);
            handshake.WriteSRPRequest(result);

            connection.SendMessage(result, NetDeliveryMethod.ReliableUnordered, 0);
            connection.Tag = handshake;

            #if DEBUG
            Console.WriteLine(">> Autenticating with user:{0} and pass:{1} <<", username, password);
            #endif
        }
开发者ID:SleeplessByte,项目名称:lidgren-srp6a,代码行数:22,代码来源:NetLobby.cs

示例3: SendMessage

 /// <summary>
 /// Sends a message to a specific connection
 /// </summary>
 public void SendMessage(NetBuffer data, NetConnection recipient, NetChannel channel)
 {
     if (recipient == null)
         throw new ArgumentNullException("recipient");
     recipient.SendMessage(data, channel);
 }
开发者ID:rcrowe,项目名称:ees_xplane,代码行数:9,代码来源:NetServer.cs

示例4: SendPacket

 public void SendPacket(Packet P, NetConnection Connection)
 {
     Connection.SendMessage(P.ToOutgoing(_client), NetDeliveryMethod.ReliableOrdered, 0);
 }
开发者ID:hipolipolopigus,项目名称:SkyNet_Old,代码行数:4,代码来源:Client_Model2.cs

示例5: AddPlayer

        static void AddPlayer(NetConnection connection)
        {
            var playerId = connections.Add(connection);
            var tag = connection.Tag as Player;

            tag.Id = (ushort)playerId;

            var idMessage = peer.CreateMessage(3);
            idMessage.Write(RPCUtils.SetPlayerId);
            idMessage.Write(tag.Id);

            connection.SendMessage(idMessage, NetDeliveryMethod.ReliableOrdered, Channels.STATIC_UTILS);

            Debug.Log("sent id to player {0}", tag.Id);

            OnPlayerConnected(tag);
        }
开发者ID:Antaresgames,项目名称:PNet,代码行数:17,代码来源:PNetServer.cs

示例6: HostSendMessage

 public static void HostSendMessage(NetConnection client,KSPPacket packet)
 {
     NetOutgoingMessage om = netServer.CreateMessage();
     om.Write((byte)packet.MessageType);
     packet.Encode(om);
     client.SendMessage(om, NetDeliveryMethod.ReliableOrdered, 0);
 }
开发者ID:TomCaserta,项目名称:KSPMulti,代码行数:7,代码来源:Main.cs

示例7: SendFile

 private static void SendFile(string FileName, NetConnection sendto)
 {
     byte[] item = System.IO.File.ReadAllBytes(FileName);
     NetOutgoingMessage msg = server.CreateMessage();
     msg.Write("###FILE###");
     msg.Write("");
     msg.Write(item.Length + 2);
     msg.Write(item);
     sendto.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
 }
开发者ID:Vbitz,项目名称:CodeCrusade,代码行数:10,代码来源:Program.cs

示例8: onClientFullyConnected

        private void onClientFullyConnected(NetConnection connection)
        {
            var newPlayerId = this.connections[connection];
            var newPlayer = this.players.First(p => p.ID == newPlayerId);

            var otherClientConnections = this.connections
                .Where(c => c != connection)
                .Where(c => c.Status == NetConnectionStatus.Connected)
                .ToList();

            // tell other clients about this player
            if (otherClientConnections.Count > 0)
            {
                var newPlayerMessage = this.server.CreateMessage();
                newPlayerMessage.Write((byte)LobbyMessageType.NewPlayer);
                newPlayerMessage.Write(newPlayer.ID.Simple);
                newPlayerMessage.Write(newPlayer.Name);

                this.server.SendMessage(newPlayerMessage, otherClientConnections, NetDeliveryMethod.ReliableOrdered, 0);
            }

            var allOthersMessage = this.server.CreateMessage();
            allOthersMessage.Write((byte)LobbyMessageType.NewPlayers);
            allOthersMessage.Write((byte)(otherClientConnections.Count + 1));
            foreach (var p in this.players.Where(p => p.ID != newPlayerId)
                .Where(p =>
                {
                    var c = this.connections[p.ID];
                    return c == null || c.Status == NetConnectionStatus.Connected;
                }))
            {
                // collect all players
                allOthersMessage.Write(p.ID.Simple);
                allOthersMessage.Write(p.Name);
            }
            // tell this client about other players
            connection.SendMessage(allOthersMessage, NetDeliveryMethod.ReliableOrdered, 0);

            // add client to visible player list
            this.form.Invoke(new Action(() =>
                this.form.AddPlayer(newPlayer.ID, newPlayer.Name)
                ));
        }
开发者ID:BobTheHornyProgrammer,项目名称:syzygy,代码行数:43,代码来源:LobbyGameHandler.cs


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