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 + ")")); } }
//------------------------------------------------------------------------------------Event Handler-------------------------------------------------------------------------------- private void InterfaceChannel_Closed(object sender, EventArgs e) { IContextChannel ThisContext = (IContextChannel)sender; CallBackHandler.RemoveInterfaceConnection(ThisContext.SessionId); AstroData.UnsubscribeBySessionID(ThisContext.SessionId); }
private void StationChannel_Closed(object sender, EventArgs e) { IContextChannel ThisContext = (IContextChannel)sender; CallBackHandler.RemoveSiteConnection(ThisContext.SessionId); if (AstroData.IsStationConnected(ThisContext.SessionId)) { STATIONNAME ThisStation = AstroData.GetStationName(ThisContext.SessionId); TTCSLog.NewLogInformation(ThisStation, DateTime.UtcNow, "Station name : " + ThisStation.ToString() + " is now disconnceted.", LogType.COMMUNICATION, null); AstroData.SetStationDisconnected(ThisContext.SessionId); AstroData.StationDisconnected(ThisStation); } }
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 + ")")); } }