示例#1
0
        //public static T CreateNew<T>(USSDTcpListenerConfigurationSection ussdTcpListenerConfigurationSection)
        //    where T : USSDTCPListener, new()
        //{
        //    USSDTCPListener result = new T();
        //    result.name = ussdTcpListenerConfigurationSection.Name;
        //    result.address = ussdTcpListenerConfigurationSection.Address;
        //    result.port = ussdTcpListenerConfigurationSection.Port;
        //    result.sendBufferSize = ussdTcpListenerConfigurationSection.SendBufferSize;
        //    result.sendTimeout = ussdTcpListenerConfigurationSection.SendTimeout;
        //    result.receiveBufferSize = ussdTcpListenerConfigurationSection.ReceiveBufferSize;
        //    result.receiveTimeout = ussdTcpListenerConfigurationSection.ReceiveTimeout;
        //    return result as T;
        //}
        #endregion

        #region Public Methods
        public USSDTCPListener(USSDTcpListenerConfigurationSection ussdTcpListenerConfigurationSection)
        {
            this.AutoReconnectWhenConnectionIsLost = ussdTcpListenerConfigurationSection.AutoReconnectWhenConnectionIsLost;
            this.address           = ussdTcpListenerConfigurationSection.Address;
            this.port              = ussdTcpListenerConfigurationSection.Port;
            this.sendBufferSize    = ussdTcpListenerConfigurationSection.SendBufferSize;
            this.sendTimeout       = ussdTcpListenerConfigurationSection.SendTimeout;
            this.receiveBufferSize = ussdTcpListenerConfigurationSection.ReceiveBufferSize;
            this.receiveTimeout    = ussdTcpListenerConfigurationSection.ReceiveTimeout;
            this.name              = ussdTcpListenerConfigurationSection.Name;
            this.packetTerminator  = System.Text.Encoding.UTF8.GetBytes(ussdTcpListenerConfigurationSection.PacketTerminator);
            this.mobileNetwork     = (MobileNetworks.MobileNetwork)Enum.Parse(typeof(MobileNetworks.MobileNetwork), ussdTcpListenerConfigurationSection.MobileNetwork, true);
            this.pingInterval      = ussdTcpListenerConfigurationSection.PingInterval;
        }
示例#2
0
 public static IUSSDHandler GetHandler(MobileNetworks.MobileNetwork mobileNetwork, String requestData, USSDHandlerRequestType.RequestTypes inputRequestType)
 {
     foreach (KeyValuePair <String, Type> ussdHandlerDefinition in ussdHandlerFactory.ussdhandlers)
     {
         Type            ussdHandlerType        = ussdHandlerDefinition.Value;
         ConstructorInfo ussdHandlerConstructor = ussdHandlerType.GetConstructor(new Type[] { typeof(String) });
         if (ussdHandlerConstructor != null)
         {
             IUSSDHandler ussdHandler = ussdHandlerConstructor.Invoke(new Object[] { ussdHandlerDefinition.Key }) as IUSSDHandler;
             if (ussdHandler != null && ussdHandler.MobileNetwork == mobileNetwork && ussdHandler.IsValidRequest(requestData, inputRequestType))
             {
                 return(ussdHandler);
             }
         }
     }
     throw new USSDHandlerFactoryUnknownHandlerException("Unable to find USSDHandler for request data");
 }