internal void _AddHiddenClientPingChannel(int peerID) { //SERVERSIDE UDPChannel pingChannel = new UDPChannel(UDPManager._UDPMRCP + ":" + peerID, true, true, 1000, 10000); pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); this._clientsPingChannels.Add(pingChannel); }
internal void _RemoveHiddenClientPingChannel(int peerID) { //SERVERSIDE UDPChannel pingChannel = this._clientsPingChannels.Where(a => a.Name == UDPManager._UDPMRCP + ":" + peerID).FirstOrDefault(); this._clientsPingChannels.RemoveAt(this._clientsPingChannels.IndexOf(pingChannel)); pingChannel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); pingChannel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); pingChannel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); pingChannel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); pingChannel._Close(); }
/// <summary> /// Removes a UDPChannel on the instance</summary> /// <param name='channelName'>The name of the channel you want to remove.</param> /// <c>It must be registered on this instance, if a channel with that name can't be found the method will throw an exception!</c> /// <remarks>You can check if the name is registered by calling <see cref="GetChannelByName"/></remarks> public void RemoveChannel(string channelName) { UDPChannel channel = this.GetChannelByName(channelName); channel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); channel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); channel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); channel.RemoveEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); channel._Close(); this._channels.Remove(channel); }
internal void _InitHiddenChannels() { //CLIENTSIDE this._pingChannel = new UDPChannel(UDPManager._UDPMRCP, true, true, 1000, 10000); this._connectionChannel = new UDPChannel(UDPManager._UDPMRCC, true, false, 1000, 10000); this._pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); this._pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); this._pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); this._pingChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); this._connectionChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); this._connectionChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); this._connectionChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); this._connectionChannel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); }
/// <summary> /// Add a UDPChannel on the instance</summary> /// <param name='channelName'>The name of the channel you want to create. It must be unique on this instance, if a channel with the same name has already been added the method will throw an exception!<remarks>You can check if the name is already used by calling <see cref="GetChannelByName"/></remarks></param> /// <param name='guarantiesDelivery'>If true the messages sent though this channel will wait for a receipt from the target that will guaranty the delivery. It will wait during the time specified on <paramref name="retryTime"/> until what it will retry sending the message, etc... If false the message is sent once without guranty of delivery. Default is false.<remarks>The guaranty of the delivery works only if the target uses the same library (C#,AS3 or JS) to communicate over UDP!</remarks></param> /// <param name='maintainOrder'>If true it will wait for a message to be delivered before sending the next one.<remarks> Only works if <paramref name="guarantiesDelivery"/> is true</remarks></param> /// <param name='retryTime'>The number of milliseconds the channel will wait before retrying sending the message if not delivered. Default is 30.</param> /// <param name='cancelTime'>The number of milliseconds the channel will wait before canceling the message if not delivered. Default is 500.</param> public void AddChannel(string channelName, bool guarantiesDelivery = false, bool maintainOrder = false, float retryTime = 30, float cancelTime = 500) { if (this.GetChannelByName(channelName) == null) { UDPChannel channel = new UDPChannel(channelName, guarantiesDelivery, maintainOrder, retryTime, cancelTime); channel.AddEventListener <UDPManagerEvent>(UDPManagerEvent._SEND_DATA, this._SendDataFromChannel); channel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, this._DeliveredNotifForward); channel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, this._RetryNotifForward); channel.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, this._CancelNotifForward); this._channels.Add(channel); } else { throw new ArgumentException("channelName " + channelName + " already used"); } }