Ejemplo n.º 1
0
        /// <summary>
        /// Callback method called after attempting to connect to the media server's data port (typically 4522).
        /// </summary>
        /// <param name="ex">Any exception raised by the connection process.</param>
        protected virtual void HandleRtpConnect(Exception ex)
        {
            if (ex == null)
            {
                Reset();
                _rtpClient.Send(_rtpConnect.BuildPacket());
            }

            // This is the final step in the connection chain.
            FinalizeConnection(ex);
        }
Ejemplo n.º 2
0
        private void exit()
        {
            SpinWait.SpinUntil(() => client.P2PSocketList.Count == 0);

            if (type == ProtocolType.Udp)
            {
                using (Packet packet = new Packet(client.RemoteEndPoint))
                {
                    packet.BeginWrite(PacketType.CONNECTION_LOST);
                    client.Send(packet);
                }
            }
            client.PushPacket(PacketType.CONNECTION_LOST, "主動斷線");
        }
Ejemplo n.º 3
0
 private void SendCurrentFrame()
 {
     if (IsPlaying)
     {
         netClient.Send(fileIterator.CurrentLine);
     }
 }
Ejemplo n.º 4
0
 public virtual void Tell(byte Code, object Parameter, bool _Lock = true)
 {
     using (Packet packet = new Packet(socket))
     {
         packet.BeginWrite(PacketType.P2P_Tell);
         packet.WriteSendData(new SendData(Code, Parameter), Key, _Lock ? EncryptAndCompress.LockType.AES : EncryptAndCompress.LockType.None);
         if (NAT)
         {
             client.P2PNATPacketSend(packet);
         }
         else
         {
             client.Send(packet);
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Registers the local client on the audio server using an out-of-band control channel.
 /// </summary>
 protected virtual void RegisterClientOnServer()
 {
     ClientLogger.Debug("Registering client {0} on server.", _rtpConnect.SsrcId);
     _commandSet = new MediaCommandSet {
         new MediaCommandCreateRoom(_roomId), new MediaCommandAddClient(_roomId, _rtpConnect.SsrcId.ToString())
     };
     _expectingControlData = true;
     _controlClient.Send(_commandSet.ToString());             // -> HandleControlData()
 }
Ejemplo n.º 6
0
        public static void SendShutdownServer(INetClient client)
        {
            using (var packet = new NetPacket())
            {
                packet.Write((ushort)OpCode.Shutdown);

                client.Send(packet);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sends a chat message.
        /// </summary>
        /// <param name="client">Current client.</param>
        /// <param name="message">Message to send.</param>
        public static void SendChatMessage(INetClient client, string message)
        {
            using (INetPacketStream packet = new NetPacket())
            {
                packet.Write <byte>((byte)ChatPacketType.Chat);
                packet.Write <string>(message);

                client.Send(packet);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sends a request to change the name of the client.
        /// </summary>
        /// <param name="client">Current client.</param>
        /// <param name="name">New client name.</param>
        public static void SetName(INetClient client, string name)
        {
            using (INetPacketStream packet = new NetPacket())
            {
                packet.Write <byte>((byte)ChatPacketType.SetName);
                packet.Write <string>(name);

                client.Send(packet);
            }
        }
Ejemplo n.º 9
0
        public static void SendStopScriptDomain(INetClient client)
        {
            using (var packet = new NetPacket())
            {
                packet.Write((ushort)OpCode.StopScriptDomain);

                client.Send(packet);
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 10
0
        public static void SendWorkingDirectory(INetClient client, string workingDirectory)
        {
            using (var packet = new NetPacket())
            {
                packet.Write((ushort)OpCode.SetWorkingDirectory);
                packet.Write(workingDirectory);

                client.Send(packet);
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 11
0
 public void Send <T>(NetCmdBase ncb)
 {
     if (typeof(T) != ncb.GetType())
     {
         LogMgr.Log("命令类型不相等:" + ncb.ToString());
         return;
     }
     if (IsConnected)
     {
         m_TCPClient.Send <T>(ncb);
     }
     //else
     //    LogMgr.Log("TCPClient don't connected, send cmd:" + ncb.ToString());
 }
Ejemplo n.º 12
0
        public static void SendAuthentication(INetClient client, WorldConfiguration worldConfiguration)
        {
            using (var packet = new NetPacket())
            {
                packet.Write((uint)ISCPacketType.AUTHENT);
                packet.Write(worldConfiguration.Id);
                packet.Write(worldConfiguration.Host);
                packet.Write(worldConfiguration.Name);
                packet.Write((byte)ISCServerType.World);
                packet.Write(worldConfiguration.ClusterId);

                // TODO: add more information to packet if needed.
                client.Send(packet);
            }
        }