public frmMain() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; //此处请设置为从代理商处取得的激活码 Leey.Net.eTerm.LicenseManager.Instance.Key = "ceshiceshiceshi"; ec = new EtermConnection(); ec.OnReadPacket += new EtermConnection.CmdResultHandler(ec_OnReadPacket); ec.OnSendPacket += new EtermConnection.PacketHandler(ec_OnSendPacket); ec.OnLogin += new Leey.Net.eTerm.Net.ObjectHandler(ec_OnLogin); ec.OnUnLogin += new Leey.Net.eTerm.Net.ObjectHandler(ec_OnUnLogin); ec.OnEtermConnectionStateChanged += new EtermConnection.EtermConnectionStateHandler(ec_OnEtermConnectionStateChanged); ec.OnGetChkCode += new EtermConnection.ChkCodeHandler(ec_OnGetChkCode); ec.OnError += new Leey.Net.eTerm.Net.ErrorHandler(ec_OnError); //ec.LocalIP = "10.108.16.20"; //连续执行指令之间的间隔。 对于新申请的航信配置可适当设置此参数,避免指令执行过快出现 Transation in process 错误。 ec.ExeInterval = 1000; //实现REMOTING HttpServerChannel channel = new HttpServerChannel(8081); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemotableObject), "HelloWorld.rem", WellKnownObjectMode.Singleton); RemotableObjects.Cache.Attach(this); //启动日志记录 LogManager.Instance.LoadConfiguration(); LogManager.Instance.Log.Info("应用程序启动"); }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup // server registration using http IDictionary properties = new Hashtable(); properties["machineName"] = Properties.Settings.Default.hMailServerWebAdminMachineName; HttpServerChannel channel = new HttpServerChannel(properties, null); ChannelServices.RegisterChannel(channel, false); LifetimeServices.LeaseTime = TimeSpan.FromMinutes(10); LifetimeServices.RenewOnCallTime = TimeSpan.FromMinutes(15); RemotingConfiguration.RegisterWellKnownServiceType(new WellKnownServiceTypeEntry( typeof(hMailServerNetRemote.ClassFactory), "Remote.soap", WellKnownObjectMode.SingleCall )); // client registration (for calling a server) using http BinaryClientFormatterSinkProvider clnt = new BinaryClientFormatterSinkProvider(); HttpClientChannel client = new HttpClientChannel((IDictionary)null, clnt); ChannelServices.RegisterChannel(client, false); }
static void ShowChannelProperties(IChannelReceiver channel) { Console.WriteLine("Name: {0}", channel.ChannelName); Console.WriteLine("Priority: {0}", channel.ChannelPriority); if (channel is TcpChannel) { TcpChannel tcpChannel = channel as TcpChannel; Console.WriteLine("is secured: {0}", tcpChannel.IsSecured); } if (channel is HttpServerChannel) { HttpServerChannel httpChannel = channel as HttpServerChannel; Console.WriteLine("Scheme: {0}", httpChannel.ChannelScheme); } ChannelDataStore data = (ChannelDataStore)channel.ChannelData; if (data != null) { foreach (string uri in data.ChannelUris) { Console.WriteLine("URI: " + uri); } } Console.WriteLine(); }
public void Start() { try { IMS.mapDocument.MapAdded += new gView.Framework.UI.MapAddedEvent(IMS.mapDocument_MapAdded); IMS.mapDocument.MapDeleted += new gView.Framework.UI.MapDeletedEvent(IMS.mapDocument_MapDeleted); IMS.LoadConfigAsync(); _channel = new HttpServerChannel(IMS.Port); ChannelServices.RegisterChannel(_channel, false); //Register channel RemotingConfiguration.RegisterWellKnownServiceType( typeof(MapServerInstanceType), "MapServer", WellKnownObjectMode.Singleton); //Console.WriteLine("Server ON at port number:"+Functions.Port); //Console.WriteLine("Please press enter to stop the server."); } catch (Exception ex) { if (Functions.log_errors) { Logger.Log(loggingMethod.error, "Server Start: " + ex.Message); } System.Threading.Thread.Sleep(3000); System.Environment.Exit(1); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //load the icon using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("AnAppADay.JediSpeak.Server.Icon.ico")) { _icon.Icon = new Icon(s); } MenuItem[] items = new MenuItem[2]; items[1] = new MenuItem("Exit"); items[1].Click += new EventHandler(Exit_Click); items[0] = new MenuItem("About"); items[0].Click += new EventHandler(About_Click); _icon.ContextMenu = new ContextMenu(items); _icon.Visible = true; HttpServerChannel channel; RemotingConfiguration.RegisterWellKnownServiceType(typeof(JediSpeak), "AnAppADay.JediSpeak.Server/JediSpeak", WellKnownObjectMode.Singleton); channel = new HttpServerChannel(8911); channel.StartListening(null); Application.Run(); }
static void Main(string[] args) { HttpServerChannel channel = new HttpServerChannel(12345); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(BankLogic), "Bank", WellKnownObjectMode.SingleCall); Console.ReadLine(); }
/// <summary> /// 服务器端注册指定的服务 /// </summary> /// <param name="port"></param> public static void RegSvr(int port) { //创建通信侦听通道对象 HttpServerChannel channel = new HttpServerChannel(port); //注册通信侦听通道 ChannelServices.RegisterChannel(channel, false); }
private void Form1_Load(object sender, System.EventArgs e) { hts = new HttpServerChannel(8228); ChannelServices.RegisterChannel(hts); RemotingConfiguration.RegisterWellKnownServiceType(typeof(CustomerLoader), "CustomerLoader", WellKnownObjectMode.Singleton); textBox1.Text = "HTTP Channel Registered ...\r\nWaiting on Clients Connect"; }
private void StopChannel() { if (_channel == null) { throw new Exception("There is no active channel?!"); } _channel.StopListening(null); _channel = null; }
private void CreateAndStartChannel() { if (_channel != null) { throw new Exception("How did you make another channel when one is active?!"); } _channel = new HttpServerChannel(Int32.Parse(textBox1.Text)); _channel.StartListening(null); }
public ParameterServer(int portNumber) { _channel = new HttpServerChannel("param", portNumber, new XmlRpcServerFormatterSinkProvider()); var tmp = new Uri(_channel.GetChannelUri()); ParameterServerUri = new Uri("http://" + Ros.HostName + ":" + tmp.Port + "/param"); ChannelServices.RegisterChannel(_channel, false); RemotingServices.Marshal(this, "param"); }
private static HttpServerChannel Ctor3() { //<snippet13> string name = "RemotingServer"; int port = 9090; HttpServerChannel serverChannel = new HttpServerChannel(name, port); //</snippet13> return(serverChannel); }
static void Main(string[] args) { HttpServerChannel myChannel = new HttpServerChannel(8080); ChannelServices.RegisterChannel(myChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ListServer.CompanyLists), "CompanyLists", WellKnownObjectMode.Singleton); System.Console.WriteLine("Press [Enter] to exit..."); System.Console.ReadLine(); }
static void Main(string[] args) { HttpServerChannel httpChannel = new HttpServerChannel(12345); ChannelServices.RegisterChannel(httpChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(Library.Catalog), "Catalog.rem", WellKnownObjectMode.Singleton); Console.WriteLine("Server started. Press enter to end..."); Console.ReadLine(); }
public static void Main(string[] args) { // Create the server channel. HttpServerChannel serverChannel = new HttpServerChannel(9090); // Register the server channel. ChannelServices.RegisterChannel(serverChannel); // Display the channel's scheme. Console.WriteLine("The channel scheme is {0}.", serverChannel.ChannelScheme); // Display the channel's URI. Console.WriteLine("The channel URI is {0}.", serverChannel.GetChannelUri()); // Expose an object for remote calls. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "RemoteObject.rem", WellKnownObjectMode.Singleton); // Get the channel's sink chain. IServerChannelSink sinkChain = serverChannel.ChannelSinkChain; Console.WriteLine( "The type of the server channel's sink chain is {0}.", sinkChain.GetType().ToString()); // See if the channel wants to listen. bool wantsToListen = serverChannel.WantsToListen; Console.WriteLine( "The value of WantsToListen is {0}.", wantsToListen); // Parse the channel's URI. string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = serverChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); Console.WriteLine("The object URL is {0}.", objectUrl); } // Wait for the user prompt. Console.WriteLine("Press ENTER to exit the server."); Console.ReadLine(); Console.WriteLine("The server is exiting."); }
private static HttpServerChannel Ctor4() { //<snippet14> string name = "RemotingServer"; int port = 9090; IServerChannelSinkProvider sinkProvider = null; HttpServerChannel serverChannel = new HttpServerChannel(name, port, sinkProvider); //</snippet14> return(serverChannel); }
static void Main( ) { try { string myString; // <Snippet2> int myPort = 8085; // Creating the 'IDictionary' to set the server object properties. IDictionary myDictionary = new Hashtable(); myDictionary["name"] = "MyServerChannel1"; myDictionary["priority"] = 2; myDictionary["port"] = 8085; // Set the properties along with the constructor. HttpServerChannel myHttpServerChannel = new HttpServerChannel(myDictionary, new BinaryServerFormatterSinkProvider()); // Register the server channel. ChannelServices.RegisterChannel(myHttpServerChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyHelloServer), "SayHello", WellKnownObjectMode.SingleCall); myHttpServerChannel.WantsToListen = true; // Start listening on a specific port. myHttpServerChannel.StartListening((object)myPort); // Get the name of the channel. Console.WriteLine("ChannelName : " + myHttpServerChannel.ChannelName); // Get the channel priority. Console.WriteLine("ChannelPriority : " + myHttpServerChannel.ChannelPriority); // Get the schema of the channel. Console.WriteLine("ChannelScheme : " + myHttpServerChannel.ChannelScheme); // Get the channel URI. Console.WriteLine("GetChannelUri : " + myHttpServerChannel.GetChannelUri()); // Indicates whether 'IChannelReceiverHook' wants to be hooked into the outside listener service. Console.WriteLine("WantsToListen : " + myHttpServerChannel.WantsToListen); // </Snippet2> // <Snippet3> // Extract the channel URI and the remote well known object URI from the specified URL. Console.WriteLine("Parsed : " + myHttpServerChannel.Parse(myHttpServerChannel.GetChannelUri() + "/SayHello", out myString)); Console.WriteLine("Remote WellKnownObject : " + myString); Console.WriteLine("Hit <enter> to stop listening..."); Console.ReadLine(); // Stop listening to channel. myHttpServerChannel.StopListening((object)myPort); // </Snippet3> Console.WriteLine("Hit <enter> to exit..."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("The following exception is raised on server side : " + ex.Message); } }
static void Main(string[] args) { /* Uncomment out the Setting Channel Properties region for page 15 of the chapter. * Then comment out the TcpChannels region * */ #region Setting Channel Properties IDictionary properties = new Hashtable(); properties["name"] = "TCP Channel with a SOAP Formatter"; properties["priority"] = "20"; properties["port"] = "8086"; SoapServerFormatterSinkProvider sinkProvider = new SoapServerFormatterSinkProvider(); TcpServerChannel tcpChannel = new TcpServerChannel(properties, sinkProvider); ShowChannelProperties(tcpChannel); #endregion #region TcpChannels // TcpServerChannel tcpChannel = new TcpServerChannel(8086); // ShowChannelProperties(tcpChannel); #endregion #region HttpChannel HttpServerChannel httpChannel = new HttpServerChannel(8085); ShowChannelProperties(httpChannel); #endregion #region RegisterChannels ChannelServices.RegisterChannel(tcpChannel); ChannelServices.RegisterChannel(httpChannel); #endregion /* * HttpServerChannel channel = * (HttpServerChannel)ChannelServices.GetChannel("http"); * channel.StopListening(null); */ RemotingConfiguration.RegisterWellKnownServiceType( typeof(Hello), "Hi", WellKnownObjectMode.SingleCall); System.Console.WriteLine("hit to exit"); System.Console.ReadLine(); }
private static HttpServerChannel Ctor1() { //<snippet11> HttpServerChannel serverChannel = new HttpServerChannel(); serverChannel.AddHookChannelUri("http://localhost:9090"); //</snippet11> // return serverChannel; // Return good channel until fix. return(Ctor2()); }
private static HttpServerChannel Ctor2() { //<snippet12> System.Collections.Hashtable properties = new System.Collections.Hashtable(); properties["port"] = 9090; IServerChannelSinkProvider sinkProvider = null; HttpServerChannel serverChannel = new HttpServerChannel( properties, sinkProvider); //</snippet12> return(serverChannel); }
public void StartRPCServer() { var serv = new SoapServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; var channel = new HttpServerChannel("server_remotezeus", 9254, serv); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteZeus), "RemoteZeus", WellKnownObjectMode.SingleCall); RemoteZeus.ZeusWin = this; }
public void StartHttpServer() { if (serverChannel != null) { return; } serverChannel = new HttpServerChannel("HttpServerChannelTests", port); ChannelServices.RegisterChannel(serverChannel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "RemoteObject.rem", WellKnownObjectMode.Singleton); }
public MasterServer(int portNumber) { _channel = new HttpServerChannel("master", portNumber, new XmlRpcServerFormatterSinkProvider()); var tmp = new Uri(_channel.GetChannelUri()); MasterUri = new Uri("http://" + Ros.HostName + ":" + tmp.Port); ChannelServices.RegisterChannel(_channel, false); RemotingServices.Marshal(this, "/"); _parameterServer = new ParameterServer(MasterUri); _logger.Info(m => m("MasterServer launched {0}", MasterUri.ToString())); }
public void Start() { WebLabDotNetDummy.Server = this.experimentServer; IServerChannelSinkProvider formatter = new CookComputing.XmlRpc.XmlRpcServerFormatterSinkProvider(); HttpServerChannel channel = new HttpServerChannel("WebLab-Deusto", this.port, formatter); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(WebLabDeusto.WebLabDotNetDummy), this.servicePath, WellKnownObjectMode.Singleton ); }
static void Main () { HttpServerChannel channel = new HttpServerChannel (8000); #if NET_2_0 ChannelServices.RegisterChannel (channel, false); #else ChannelServices.RegisterChannel (channel); #endif RemotingConfiguration.RegisterWellKnownServiceType ( typeof (RemoteInterfaceFactory), "RemoteInterfaceFactory.soap", WellKnownObjectMode.Singleton); Console.ReadLine (); }
static void Main(string[] args) { Certificate.OpenCertificate(); Console.WriteLine("PractiSES Root Server started."); HttpServerChannel channel = new HttpServerChannel(88); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(PractiSES.RootServerObject), "PractiSES_Root", WellKnownObjectMode.SingleCall); System.Console.ReadLine(); }
static void Main(string[] args) { HttpServerChannel serverChannel = new HttpServerChannel(8234); ChannelServices.RegisterChannel(serverChannel, false); // Following line won't work at runtime as there is no parameterless constructor //RemotingConfiguration.RegisterWellKnownServiceType(typeof(CountingService), // "CountingService.rem", WellKnownObjectMode.Singleton); CountingService countingService = new CountingService(5); RemotingServices.Marshal(countingService, "CountingService.rem"); Console.WriteLine("Press enter to exit."); Console.ReadLine(); }
/// <summary> /// 监听Http信道 /// </summary> /// <param name="port">端口</param> /// <param name="channelName">信道名称</param> public void ListenHttpChannel(int port, string channelName, FormatterSinkProviderType fspt = FormatterSinkProviderType.Binary) { IDictionary props = new Hashtable(); props["port"] = port; props["name"] = channelName; IServerChannelSinkProvider sckp = sinkBinaryProvider; if (fspt == FormatterSinkProviderType.Soap) { sckp = sinkSoapProvider; } HttpServerChannel srvChannel = new HttpServerChannel(props, sckp); ChannelServices.RegisterChannel(srvChannel, false); httpChannels.Add(channelName); }
/// <summary> /// Inicializa el hosr remoting por marshalling de un objeto (singleton) /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event argument.</param> private void InicializarPorMarsall_Click(object sender, EventArgs e) { try { HttpServerChannel channel = new HttpServerChannel(8989); ChannelServices.RegisterChannel(channel, false); _myObjetoRemoto = new MyObjetoRemoto(); RemotingServices.Marshal(_myObjetoRemoto, "MyObjetoRemoto.rem"); MessageBox.Show("Objeto Inicializado con exito !", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); gbxMarshalling.Enabled = true; btnInicializeHost.Enabled = false; } catch (Exception er) { MessageBox.Show(string.Format("Error:\n{0}", er.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RegisterPort(int port) { IMS.ServicesPath = gView.Framework.system.SystemVariables.ApplicationDirectory + @"\mapServer\Services\" + port; IMS.Port = port; IMS.mapDocument.MapAdded += new gView.Framework.UI.MapAddedEvent(IMS.mapDocument_MapAdded); IMS.mapDocument.MapDeleted += new gView.Framework.UI.MapDeletedEvent(IMS.mapDocument_MapDeleted); IMS.LoadConfigAsync(); _channel = new HttpServerChannel(port); ChannelServices.RegisterChannel(_channel); //Register channel RemotingConfiguration.RegisterWellKnownServiceType( typeof(MapServerInstanceType), "MapServer", WellKnownObjectMode.Singleton); }
static void Main () { SoapServerFormatterSinkProvider sfsp = new SoapServerFormatterSinkProvider (); sfsp.TypeFilterLevel = TypeFilterLevel.Full; HttpServerChannel channel = new HttpServerChannel ("Serv", 8080, sfsp); #if NET_2_0 ChannelServices.RegisterChannel (channel, false); #else ChannelServices.RegisterChannel (channel); #endif ServerImpl impl = new ServerImpl (); RemotingServices.Marshal (impl, "Server.rem"); channel.StartListening (null); Console.ReadLine (); channel.StopListening (null); }
/// <summary> /// Server /// </summary> /// <param name="sServerName"></param> /// <param name="iPort"></param> /// <param name="sAppURI"></param> public void CreateServerChannel(string sServerName, int iPort, string sAppURI) { try { //string sComputerName = System.Windows.Forms.SystemInformation.ComputerName; IPHostEntry oIPHostEntry = Dns.GetHostEntry(sServerName); IPAddress[] oIPAddress = oIPHostEntry.AddressList; RemotingConfiguration.Configure("Remoting.config", false); HttpServerChannel oHttpServerChannel = new HttpServerChannel(iPort); ChannelServices.RegisterChannel(oHttpServerChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(System.Type.GetType("Server.ServerClass, Server"), sAppURI, WellKnownObjectMode.Singleton); oRemoteServer = (IRemoteClass)Activator.GetObject(typeof(IRemoteClass), "http://" + sServerName + ":" + iPort + "/" + sAppURI); } catch { } }