static void Main(string[] args) { LogInitialiser.InitLog4Net(); var rm = new DummyResourceManager { SwitchIpAddress = "127.0.0.1", SwitchName = "RATCOW", }; rm.AddExtension("1003"); rm.AddExtension("1007"); rm.AddVdn("1315"); var server = new ServerManager(new DummyEventProcessor(), rm) { CallServerName = rm.SwitchName, CallServerIpAddress = rm.SwitchIpAddress, Address = "127.0.0.1", Port = 4721, Secure = false }; server.Start(); Console.ReadLine(); server.Stop(); }
static void Main(string[] args) { LogInitialiser.InitLog4Net(); var logger = LogProvider.For <Program>(); logger.Debug("This is a test"); }
/// <summary> /// DmccProtocolType defaults to v63 as we can easily test agains that level. /// </summary> public Api(DmccProtocolType protocol = DmccProtocolType.v63) { LogInitialiser.InitLog4Net(); logger = LogProvider.For <Api>(); DmccProtocolVersion = protocol; this.protocol = DmccClientDataProtocolFactory.Create(DmccProtocolVersion); SessionId = string.Empty; }
static void Main(string[] args) { //initiate the logging framework LogInitialiser.InitLog4Net(); var logger = LogProvider.For <Program>(); var extension = new DeviceData { Extension = 1233 }; var extension2 = new DeviceData { Extension = 1237 }; var vdn = new DeviceData { Extension = 1335 }; //var makecallInvokeId = int.MinValue; var vdnrrInvokeId = int.MinValue; var vdrRouteRegistered = string.Empty; var callServer = "127.0.0.1"; var dmccServer = "127.0.0.1"; var user = "******"; var password = "******"; var api = new Api { CallServer = callServer, CallServerName = "RATCOW", DmccServer = dmccServer, User = user, Password = password }; //hook the event handler so we can display some "useful" data. api.CtsaEvent += (object s, CstaEventArgs e) => { logger.Debug(e.RawEventData.ToString()); if (e.RawEventData is StartApplicationSessionPosResponse saspr) { Console.WriteLine($"Success {saspr.sessionID}"); } else if (e.RawEventData is UnmappedData u) { Console.WriteLine($"{u.Data}"); //debug an UnmappedData event } else if (extension.GetDeviceIdInvokeId == e.InvokeId && e.RawEventData is GetDeviceIdResponse gdidr) { //check the user data if (e.UserData is TestData td) { Debug.Assert(string.Compare(td.Data, TEST_CONST) == 0, "UserData validity failed"); } //we got the deviceId we requested extension.DeviceId = gdidr.device; Console.WriteLine($"Success {gdidr.device.Value}, InvokeId: {e.InvokeId}"); //we will now monitor the device extension.MonitorInvokeId = api.MonitorStart(extension.DeviceId, true); Console.WriteLine($"MonitorStartRequest {gdidr.device.Value}, InvokeId: {extension.MonitorInvokeId}"); } else if (extension.GetDeviceIdInvokeId == e.InvokeId && e.RawEventData is GetThirdPartyDeviceIdResponse gtpdidr) { //we got the deviceId we requested extension.DeviceId = gtpdidr.device; Console.WriteLine($"Success {gtpdidr.device.Value}, InvokeId: {e.InvokeId}"); //we will now monitor the device extension.MonitorInvokeId = api.MonitorStart(extension.DeviceId, true); Console.WriteLine($"MonitorStartRequest {gtpdidr.device.Value}, InvokeId: {extension.MonitorInvokeId}"); } else if (extension2.GetDeviceIdInvokeId == e.InvokeId && e.RawEventData is GetDeviceIdResponse gdidr2) { //we got the deviceId we requested extension2.DeviceId = gdidr2.device; Console.WriteLine($"Success {gdidr2.device.Value}, InvokeId: {e.InvokeId}"); //we will now make call //makecallInvokeId = api.MakeCall(extensionDeviceId, extension2DeviceId); } else if (extension.MonitorInvokeId == e.InvokeId && e.RawEventData is MonitorStartResponse msr) { extension.MonitorCrossReferenceId = msr.monitorCrossRefID; Console.WriteLine($"MonitorStartRequest {msr.monitorCrossRefID}, InvokeId: {e.InvokeId}"); } else if (vdn.MonitorInvokeId == e.InvokeId && e.RawEventData is MonitorStartResponse vdnmsr) { vdn.MonitorCrossReferenceId = vdnmsr.monitorCrossRefID; Console.WriteLine($"MonitorStartRequest {vdnmsr.monitorCrossRefID}, InvokeId: {e.InvokeId}"); vdnrrInvokeId = api.RouteRegister(vdn.DeviceId); } //else if (vdnInvokeId == e.InvokeId && e.RawEventData is GetDeviceIdResponse vgdidr) //{ // //we got the deviceId we requested // vdnDeviceId = vgdidr.device; // Console.WriteLine($"Success {vgdidr.device.Value}, InvokeId: {e.InvokeId}"); // vdnMsInvokeId = api.MonitorStart(vdnDeviceId, true); //} //else if (vdnInvokeId == e.InvokeId && e.RawEventData is GetThirdPartyDeviceIdResponse tpvgdidr) //{ // //we got the deviceId we requested // vdnDeviceId = tpvgdidr.device; // Console.WriteLine($"Success {tpvgdidr.device.Value}, InvokeId: {e.InvokeId}"); // //we will now monitor the device // vdnMsInvokeId = api.MonitorStart(vdnDeviceId, false); //} else if (vdnrrInvokeId == e.InvokeId && e.RawEventData is RouteRegisterResponse rrr) { vdrRouteRegistered = rrr.routeRegisterReqID; Console.WriteLine($"Success {rrr.routeRegisterReqID}, InvokeId: {e.InvokeId}"); } else if (e.RawEventData is UniversalFailure uf) { Console.WriteLine($"UniversalFailure:: {uf.Item}, InvokeId: {e.InvokeId}"); //debug an unknown event } else { Console.WriteLine($"{e.RawEventType.Name}, InvokeId: {e.InvokeId}"); //debug an unknown event } }; if (api.Init() && api.StartApplicationSessionAndWait()) { api.StartEventListener(); if (api.SystemRegisterAndWait()) { api.RequestSystemStatus(); //extension.GetDeviceIdInvokeId = TestGetDeviceId(api, extension.Extension); //extension2InvokeId = TestGetDeviceId(api, extension2); //extension.MonitorInvokeId = api.MonitorStart(extension.DeviceId, true); vdn.DeviceId = api.ObtainThirdPartyDeviceId(vdn.Extension.ToString()); vdn.MonitorInvokeId = api.MonitorStart(vdn.DeviceId, true); //api.GetMonitorList(); Console.WriteLine("Running - press a key to begin shot down"); Console.ReadLine(); //Okay - this is just me being lazy and ensuring events are processed before we exit. Console.WriteLine("Cleaning up....Monitors"); if (!string.IsNullOrEmpty(extension.MonitorCrossReferenceId)) { api.MonitorStop(extension.MonitorCrossReferenceId); } if (!string.IsNullOrEmpty(vdn.MonitorCrossReferenceId)) { api.MonitorStop(vdn.MonitorCrossReferenceId); } Console.ReadLine(); Console.WriteLine("Cleaning up....devices"); api.ReleaseDeviceId(vdn.DeviceId); api.ReleaseDeviceId(extension.DeviceId); //api.ReleaseDeviceId(extension2DeviceId); } else { Console.WriteLine("System register failed"); } api.RequestSystemStatus(); Console.ReadLine(); api.StopEventListener(); api.Done(); } }