Example #1
0
        public ReturnKnowType AstroCreateStation(STATIONNAME StationName, Double Version = 0)
        {
            try
            {
                if (Version != RequirePackageVersion)
                {
                    return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co003) Failed to create " + StationName + ". Your client version is " + Version + " (Require version " + RequirePackageVersion + ")."));
                }
                else
                {
                    OperationContext context      = OperationContext.Current;
                    ServerCallBack   SiteCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>();
                    CallBackHandler.AddSiteConnection(StationName, context.SessionId, SiteCallBack);

                    OperationContext.Current.Channel.Closed  += StationChannel_Closed;
                    OperationContext.Current.Channel.Faulted += StationChannel_Closed;

                    ReturnKnowType CreateSiteResult = AstroData.CreateStation(StationName, context.SessionId, SiteCallBack);
                    return(CreateSiteResult);
                }
            }
            catch (Exception e)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co001) Failed to create site at TTCSCreateSite see. (" + e.Message + ")"));
            }
        }
Example #2
0
        public void SubscribeInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName)
        {
            ServerCallBack   ClientCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>();
            OperationContext Context        = OperationContext.Current;

            AstroData.SubscribeInformation(StationName, DeviceName, FieldName, Context.SessionId, ClientCallBack);
        }
Example #3
0
 public SocketServer(/*int PortNr,ServerCallBack RxServerCB*/)
 {
     iPortNr = 8221;           // PortNr;
     pfServerReceivedData = null;
     AnzTxDat             = 0;
     AnzRxDat             = 0;
 }
Example #4
0
		public SocketServer(/*int PortNr,ServerCallBack RxServerCB*/)
		{
			iPortNr =8221;// PortNr;
			pfServerReceivedData=null;
			AnzTxDat = 0;
			AnzRxDat = 0;
		}
Example #5
0
 /// <summary>
 /// 注册消息回调事件
 /// </summary>
 public static void Register(MessageType type, ServerCallBack method)
 {
     if (!_callBacks.ContainsKey(type))
     {
         _callBacks.Add(type, method);
     }
     else
     {
         Console.WriteLine("注册了相同的回调事件");
     }
 }
Example #6
0
 private void InitonClientProxy()
 {
     if (LinkServerSuccess)
     {
         StopServerLinkNotify();
     }
     _CallBack = new ServerCallBack();
     RegistCallBackEventHandle();
     _InstanceContext = new InstanceContext(_CallBack);
     _channelFactory  = new DuplexChannelFactory <INetPlanContract>(_InstanceContext, "AircomEndPoint");
     _Proxy           = _channelFactory.CreateChannel();
 }
Example #7
0
        public static ReturnKnowType SubscribeByCommmanName(ServerCallBack ClientCallBack, String ClientSessionID, STATIONNAME StationName, DEVICECATEGORY DeviceName, String CommandName)
        {
            try
            {
                SubscribeStructure.SubscribeType SubscribeType = GetSubscribeType(StationName, DeviceName, CommandName);
                DuplicationSubscribeChecking(SubscribeType, ClientSessionID, StationName, DeviceName, CommandName);

                SubscribeStructure ThisSubscribe = SubscribeList.FirstOrDefault(Item => Item.StationName == StationName && Item.DeviceName == DeviceName && Item.CommandName == CommandName);

                if (ThisSubscribe == null)
                {
                    ClientSubscription ThisClient = new ClientSubscription();
                    ThisClient.ClientCallBack  = ClientCallBack;
                    ThisClient.ClientSessionID = ClientSessionID;

                    ThisSubscribe             = new SubscribeStructure();
                    ThisSubscribe.StationName = StationName;
                    ThisSubscribe.DeviceName  = DeviceName;
                    ThisSubscribe.CommandName = CommandName;
                    ThisSubscribe.Type        = SubscribeType;

                    ThisSubscribe.ClientList = new List <ClientSubscription>();
                    ThisSubscribe.ClientList.Add(ThisClient);
                }
                else
                {
                    ClientSubscription ThisClient = ThisSubscribe.ClientList.FirstOrDefault(Item => Item.ClientSessionID == ClientSessionID);

                    if (ThisClient == null)
                    {
                        ThisClient = new ClientSubscription();
                        ThisClient.ClientCallBack  = ClientCallBack;
                        ThisClient.ClientSessionID = ClientSessionID;

                        ThisSubscribe.ClientList.Add(ThisClient);
                    }
                    else
                    {
                        return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, "Your request is already exist in subscribe list. Please check."));
                    }
                }

                return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));
            }
            catch (Exception e)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to subscribe information see. (" + e.Message + ")"));
            }
        }
Example #8
0
        public ReturnKnowType AstroCreateClientInterface(String InterfaceName)
        {
            try
            {
                OperationContext context        = OperationContext.Current;
                ServerCallBack   ServerCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>();
                CallBackHandler.AddInterfaceConnection(InterfaceName, context.SessionId, ServerCallBack);

                OperationContext.Current.Channel.Closed  += InterfaceChannel_Closed;
                OperationContext.Current.Channel.Faulted += InterfaceChannel_Closed;

                return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));;
            }
            catch (Exception e)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to create client interface at TTCSCreateClientInterface see. (" + e.Message + ")"));
            }
        }
Example #9
0
        public static ReturnKnowType AddInterfaceConnection(String InterfaceName, String InterfaceSessionID, ServerCallBack SiteCallBack)
        {
            try
            {
                InterfaceConnection NewInterfaceConnection = new InterfaceConnection();
                NewInterfaceConnection.InterfaceName      = InterfaceName;
                NewInterfaceConnection.InterfaceSessionID = InterfaceSessionID;
                NewInterfaceConnection.SiteCallBack       = SiteCallBack;

                InterfaceConnectionList.Add(NewInterfaceConnection);

                return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));
            }
            catch (Exception e)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to add interface connection see. (" + e.Message + ")"));
            }
        }
Example #10
0
        public static void AddSiteConnection(STATIONNAME StationName, String SiteSessionID, ServerCallBack SiteCallBack)
        {
            SiteConnection NewSiteConnection = new SiteConnection();

            NewSiteConnection.StationName   = StationName;
            NewSiteConnection.SiteSessionID = SiteSessionID;
            NewSiteConnection.SiteCallBack  = SiteCallBack;

            SiteConnectionList.Add(NewSiteConnection);
        }
Example #11
0
 public ServerManager(int port, ServerCallBack callback)
 {
     this.port     = port;
     this.callback = callback;
 }
Example #12
0
 public CallBack(Player player, byte[] data, ServerCallBack serverCallBack)
 {
     Player         = player;
     Data           = data;
     ServerCallBack = serverCallBack;
 }