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


C# RemoteClient类代码示例

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


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

示例1: PlayerLook

 public static void PlayerLook(RemoteClient client, MinecraftServer server, IPacket _packet)
 {
     var packet = (PlayerLookPacket)_packet;
     client.Entity.Pitch = packet.Pitch;
     client.Entity.Yaw = packet.Yaw;
     client.Entity.HeadYaw = packet.Yaw;
 }
开发者ID:Booser,项目名称:Craft.Net,代码行数:7,代码来源:PlayerMovementHandlers.cs

示例2: PacketEventArgs

 /// <summary>
 /// Initializes a new instance of the <see cref="PacketEventArgs"/> class.
 /// </summary>
 /// <param name="PacketID">The packet ID.</param>
 /// <param name="RemoteClient">The remote client.</param>
 /// <param name="PacketMode">The packet mode.</param>
 /// <param name="Packet">The packet.</param>
 /// <remarks></remarks>
 public PacketEventArgs(PacketID PacketID, RemoteClient RemoteClient, PacketMode PacketMode, Packet Packet)
 {
     this.PacketID = PacketID;
     this.RemoteClient = RemoteClient;
     this.Handled = false;
     this.Packet = Packet;
 }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:15,代码来源:ServerEventArgs.cs

示例3: Animation

 public static void Animation(RemoteClient client, MinecraftServer server, IPacket _packet)
 {
     var packet = (AnimationPacket)_packet;
     var clients = server.EntityManager.GetKnownClients(client.Entity);
     foreach (var _client in clients)
         _client.SendPacket(packet);
 }
开发者ID:Booser,项目名称:Craft.Net,代码行数:7,代码来源:PlayerMovementHandlers.cs

示例4: HandlePacket

        /// <summary>
        /// Handles the packet.
        /// </summary>
        /// <param name="Server">The server.</param>
        /// <param name="Client">The client.</param>
        /// <remarks></remarks>
        public override void HandlePacket(MultiplayerServer Server, RemoteClient Client)
        {
            if (EntityID != Client.PlayerEntity.ID)
            {
                Server.KickPlayer(Client.PlayerEntity.Name, "Hacking!");
                return;
            }

            if (Action == EntityAction.Crouch || Action == EntityAction.UnCrouch)
            {
                Animation animation = Action == EntityAction.Crouch ? Animation.Crouch : Animation.UnCrouch;
                foreach (RemoteClient c in Server.GetClientsInWorldExcept(Server.GetWorld(Client), Client))
                {
                    c.PacketQueue.Enqueue(new AnimationPacket(Client.PlayerEntity.ID, animation));
                }
            }
            if (Action == EntityAction.LeaveBed)
            {
                //Unoccupy the metadata of the block
                Block bed = Server.GetWorld(Client.PlayerEntity).GetBlock(Client.PlayerEntity.OccupiedBed); //Get the block
                bed.Metadata = (byte)(bed.Metadata & ~0x4); // Remove flag
                Server.GetWorld(Client.PlayerEntity).SetBlock(Client.PlayerEntity.OccupiedBed, bed); //Set block

                Client.PlayerEntity.OccupiedBed = null; //Nullify the clients bed position

                Server.EnqueueToAllClients(new AnimationPacket(Client.PlayerEntity.ID, Animation.LeaveBed));
            }
        }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:34,代码来源:EntityActionPacket.cs

示例5: Handshake

 public static void Handshake(RemoteClient client, MinecraftServer server, IPacket _packet)
 {
     var packet = (HandshakePacket)_packet;
     if (packet.ProtocolVersion < PacketReader.ProtocolVersion)
     {
         client.SendPacket(new DisconnectPacket("Outdated client!"));
         return;
     }
     if (packet.ProtocolVersion > PacketReader.ProtocolVersion)
     {
         client.SendPacket(new DisconnectPacket("Outdated server!"));
         return;
     }
     if (server.Clients.Any(c => c.Username == packet.Username))
     {
         client.SendPacket(new DisconnectPacket(""));
         return;
     }
     client.Username = packet.Username;
     client.Hostname = packet.ServerHostname + ":" + packet.ServerPort;
     if (server.Settings.OnlineMode)
         client.AuthenticationHash = CreateHash();
     else
         client.AuthenticationHash = "-";
     if (server.Settings.EnableEncryption)
         client.SendPacket(CreateEncryptionRequest(client, server));
     else
         server.LogInPlayer(client);
 }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:29,代码来源:LoginHandlers.cs

示例6: EntityAction

        public static void EntityAction(RemoteClient client, MinecraftServer server, IPacket _packet)
        {
            var packet = (EntityActionPacket)_packet;
            switch (packet.Action)
            {
                case EntityActionPacket.EntityAction.Crouch:
                    client.Entity.IsCrouching = true;
                    break;
                case EntityActionPacket.EntityAction.Uncrouch:
                    client.Entity.IsCrouching = false;
                    break;
                case EntityActionPacket.EntityAction.StartSprinting:
                    client.Entity.IsSprinting = true;
                    break;
                case EntityActionPacket.EntityAction.StopSprinting:
                    client.Entity.IsSprinting = false;
                    break;
//                case EntityActionPacket.EntityAction.LeaveBed:
//                    client.Entity.LeaveBed();
//                    break;
            }
            if (packet.Action != EntityActionPacket.EntityAction.LeaveBed) // NOTE: Does this matter?
            {
                // TODO ?
            }
        }
开发者ID:Booser,项目名称:Craft.Net,代码行数:26,代码来源:PlayerMovementHandlers.cs

示例7: Send

        public override void Send(RemoteClient RemoteClient, Message message)
        {
            if (!(message is NetworkMessage)) throw new Exception("Network IE: Can send only networkmessage");

            message._fromId = RemoteClient.Id.ToString();
            (message as NetworkMessage).FromIP = Addresses[RemoteClient].ToString();
        }
开发者ID:DmT021,项目名称:Urfunet,代码行数:7,代码来源:NetworkIE.cs

示例8: RespawnPacket

 /// <summary>
 /// Initializes a new instance of the <see cref="RespawnPacket"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="world">The world.</param>
 /// <remarks></remarks>
 public RespawnPacket(RemoteClient client, World world)
 {
     this.Dimension = client.PlayerEntity.Dimension;
     this.Difficulty = world.Level.Difficulty;
     this.GameMode = client.PlayerEntity.GameMode;
     this.WorldHeight = World.Height;
     this.LevelType = world.Level.WorldGenerator.Name;
 }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:14,代码来源:RespawnPacket.cs

示例9: OnRecived

 public override void OnRecived(RemoteClient from, Client to)
 {
     Environment.ParentClient.Log(LogLevel.Info, "{1}: удалить файл {0}",RelativePath,from);
     base.OnRecived(from, to);
     var fs = Environment.ParentClient.FileSystem as MockFS;
     var fsobj = fs.Find(RelativePath);
     if (fsobj == null) return;
     Environment.ParentClient.FileSystem.Delete(fsobj,FSObjectEvents.remote_delete);
 }
开发者ID:DmT021,项目名称:Urfunet,代码行数:9,代码来源:DeleteFileMessage.cs

示例10: OnRecived

 public override void OnRecived(RemoteClient from, Client to)
 {
     base.OnRecived(from, to);
     if (!string.IsNullOrEmpty(RelativePath))
     srcFile = Environment.ParentClient.FileSystem.Find(RelativePath) as BaseFile;
     if (srcFile == null)
     {
         throw new Exception(string.Format("File {0} not fount (request from {1})", RelativePath, from.Id));
         Environment.ParentClient.Log(LogLevel.Error, "File {0} not fount (request from {1})", RelativePath, from.Id);
     }
 }
开发者ID:DmT021,项目名称:Urfunet,代码行数:11,代码来源:NewFileMessage.cs

示例11: ChatServer

        public ChatServer()
        {
            _packetLogger = new PacketLogger();
            _logger = new Logger() { WriteToConsole = true };
            _logger.Load(Path.Combine("logs", string.Format("chat_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"))));
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject));
                Environment.Exit(0);
            };

            _packetLogger.Load("chat_packets.log");

            _logger.Info("Loading chat_config.xml...");
            ChatConfig.Load();
            _logger.Info("Setting up servers...");
            _server = new TcpServer(IPAddress.Parse(ChatConfig.Instance.IP), ChatConfig.Instance.Port);
            _server.PacketReceived += HandlePacket;
            _server.ClientDisconnected += ClientDisconnected;
            _server.Error += Error;

            var isMono = Type.GetType("Mono.Runtime") != null;
            switch (ChatConfig.Instance.AuthRemote.Binding)
            {
                case "pipe":
                    if (isMono)
                    {
                        _logger.Error("pipe is not supported in mono, use http!");
                        Environment.Exit(1);
                        return;
                    }
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password)));
                    break;

                case "tcp":
                    if (isMono)
                    {
                        _logger.Error("pipe is not supported in mono, use http!");
                        Environment.Exit(1);
                        return;
                    }
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", ChatConfig.Instance.AuthRemote.Server, ChatConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password)));
                    break;

                case "http":
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", ChatConfig.Instance.AuthRemote.Server, ChatConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(ChatConfig.Instance.AuthRemote.Password)));
                    break;

                default:
                    _logger.Error("Invalid remote binding '{0}' for AuthRemote", ChatConfig.Instance.AuthRemote.Binding);
                    Environment.Exit(1);
                    break;
            }
        }
开发者ID:KingCrazy,项目名称:S115,代码行数:54,代码来源:ChatServer.cs

示例12: MessageRecieved

 public override void MessageRecieved(RemoteClient client, byte[] data)
 {
     if (ServerPingReceived != null)
     {
         var stream = new MinecraftStream(new MemoryStream(data));
         var eventArgs = new ServerPingEventArgs(
             stream.ReadInt32(),
             stream.ReadString(),
             stream.ReadInt32());
         ServerPingReceived(this, eventArgs);
     }
 }
开发者ID:Booser,项目名称:Craft.Net,代码行数:12,代码来源:ServerPingChannel.cs

示例13: ClientStatus

        public static void ClientStatus(RemoteClient client, MinecraftServer server, IPacket _packet)
        {
            var packet = (ClientStatusPacket)_packet;
            if (packet.Status == ClientStatusPacket.ClientStatus.InitialSpawn)
            {
                // Create a hash for session verification
                AsnKeyBuilder.AsnMessage encodedKey = AsnKeyBuilder.PublicKeyToX509(server.ServerKey);
                byte[] shaData = Encoding.UTF8.GetBytes(client.AuthenticationHash)
                    .Concat(client.SharedKey)
                    .Concat(encodedKey.GetBytes()).ToArray();
                string hash = Cryptography.JavaHexDigest(shaData);

                // Talk to session.minecraft.net
                if (server.Settings.OnlineMode)
                {
                    var webClient = new WebClient();
                    var webReader = new StreamReader(webClient.OpenRead(
                        new Uri(string.Format(sessionCheckUri, client.Username, hash))));
                    string response = webReader.ReadToEnd();
                    webReader.Close();
                    if (response != "YES")
                    {
                        client.Disconnect("Failed to verify username!");
                        return;
                    }
                }

                var eventArgs = new ConnectionEstablishedEventArgs(client);
                server.OnConnectionEstablished(eventArgs);
                if (eventArgs.PermitConnection)
                    server.LogInPlayer(client);
                else
                    client.Disconnect(eventArgs.DisconnectReason);
            }
            else if (packet.Status == ClientStatusPacket.ClientStatus.Respawn)
            {
                var world = client.Entity.World;
                client.Entity.Position = new Vector3(
                    client.Entity.SpawnPoint.X,
                    // FIXME: This seems to drop the player camera from half the height of a login spawn
                    client.Entity.SpawnPoint.Y,
                    client.Entity.SpawnPoint.Z);
                client.Entity.Health = client.Entity.MaxHealth;
                client.Entity.Food = 20;
                client.Entity.FoodSaturation = 20;
                server.EntityManager.SpawnEntity(world, client.Entity);
                client.SendPacket(new UpdateHealthPacket(client.Entity.Health, client.Entity.Food, client.Entity.FoodSaturation));
                client.SendPacket(new RespawnPacket(Dimension.Overworld, server.Settings.Difficulty, client.GameMode, World.Height, world.WorldGenerator.GeneratorName));
                client.SendPacket(new PlayerPositionAndLookPacket(client.Entity.Position.X, client.Entity.Position.Y, client.Entity.Position.Z,
                    client.Entity.Position.Y + PlayerEntity.Height, client.Entity.Yaw, client.Entity.Pitch, true));
            }
        }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:52,代码来源:LoginHandlers.cs

示例14: HeldItemChange

 public static void HeldItemChange(RemoteClient client, MinecraftServer server, IPacket _packet)
 {
     var packet = (HeldItemChangePacket)_packet;
     if (packet.SlotIndex < 10 && packet.SlotIndex >= 0)
     {
         // TODO: Move the equipment update packet to an OnPropertyChanged event handler
         client.Entity.SelectedSlot = (short)(InventoryWindow.HotbarIndex + packet.SlotIndex);
         var clients = server.EntityManager.GetKnownClients(client.Entity);
         foreach (var _client in clients)
             _client.SendPacket(new EntityEquipmentPacket(client.Entity.EntityId, EntityEquipmentPacket.EntityEquipmentSlot.HeldItem,
                                                          client.Entity.Inventory[client.Entity.SelectedSlot]));
     }
 }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:13,代码来源:InventoryHandler.cs

示例15: HandleChatPacket

 /// <summary>
 /// 
 /// </summary>
 /// <param name="packet"></param>
 public void HandleChatPacket(RemoteClient client, string chatMessage)
 {
     if (m_customEmotes.ContainsKey(chatMessage.ToLower()))
     {
         var animationController = client.GetComponent<Player.PlayerAnimationController>();
         animationController.PerformEmote(m_customEmotes[chatMessage.ToLower()]);
     }
     else
     {
         AddMessage(client.Username, chatMessage);
         client.SetChatLine(chatMessage);
     }
 }
开发者ID:SamOatesJams,项目名称:Ludumdare33,代码行数:17,代码来源:ChatInputField.cs


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