/// <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); }
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, "主動斷線"); }
private void SendCurrentFrame() { if (IsPlaying) { netClient.Send(fileIterator.CurrentLine); } }
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); } } }
/// <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() }
public static void SendShutdownServer(INetClient client) { using (var packet = new NetPacket()) { packet.Write((ushort)OpCode.Shutdown); client.Send(packet); } }
/// <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); } }
/// <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); } }
public static void SendStopScriptDomain(INetClient client) { using (var packet = new NetPacket()) { packet.Write((ushort)OpCode.StopScriptDomain); client.Send(packet); Thread.Sleep(1000); } }
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); } }
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()); }
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); } }