Beispiel #1
0
        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();
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
    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);
        }
    }
Beispiel #4
0
	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);
	}
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         button1.Enabled = false;
         Application.DoEvents();
         //create and start the channel
         _chnl = new HttpServerChannel(Int32.Parse(textBox1.Text));
         ChannelServices.RegisterChannel(_chnl, false);
         _chnl.StartListening(null);
         button2.Enabled = true;
     }
     catch (Exception ex)
     {
         CommonLib.HandleException(ex);
         button1.Enabled = true;
         button2.Enabled = false;
     }
 }