예제 #1
0
    public ChatServer()
    {
        this.users = new ArrayList();

        this.tcpServer = new TCPServer(TCP_PORT, new ExecuteCommand(Execute));
        this.udpPeer   = new UDPPeer(UDP_LOCAL_PORT, UDP_GROUP_IP, UDP_GROUP_PORT);
    }
예제 #2
0
    public UDPMulticastClient(string groupIP, int groupPort, Notify notify)
    {
        // add parameter validation here

        Console.WriteLine("initializing UDP multicast client, group=" + groupIP + ", port=" + groupPort + "...");

        this.notify = notify;

        // create communication components
        this.peer = new UDPPeer(groupPort, groupIP, groupPort);

        // start listener thread
        this.clientThread = new Thread(new ThreadStart(Run));
        this.clientThread.Start();

        Console.WriteLine("UDP multicast client initialized");
    }
    public UDPNewsServer()
    {
        Console.WriteLine("initializing server, local port=" + LOCAL_PORT + ", group IP=" + GROUP_IP + ", group port=" + GROUP_PORT + "...");

        // create controls
        this.Text = "News Server";
        this.Size = new Size(this.Size.Width, 100);

        Label l = new Label();

        l.Text     = "News:";
        l.Location = new Point(10, 10);
        l.Size     = new Size(40, l.Size.Height);
        this.Controls.Add(l);

        this.text          = new TextBox();
        this.text.Location = new Point(50, 10);
        this.text.Size     = new Size(225, this.text.Size.Height);
        this.text.Text     = "(enter news)";
        this.Controls.Add(this.text);

        this.setButton          = new Button();
        this.setButton.Text     = "Set";
        this.setButton.Location = new Point(10, 40);
        this.Controls.Add(this.setButton);

        // add an event listener for click-event
        this.setButton.Click += new System.EventHandler(OnSet);

        // add an event listener for close-event
        this.Closed += new System.EventHandler(OnClosed);

        // create communication components
        this.server = new UDPPeer(LOCAL_PORT, GROUP_IP, GROUP_PORT);

        // start communication thread
        this.serverThread = new Thread(new ThreadStart(Run));
        this.serverThread.Start();

        Console.WriteLine("initialization complete");
    }
예제 #4
0
 internal UDPClientEvent(object name, UDPPeer udpPeer, UDPDataInfo udpDataInfo = null) : base(name, udpDataInfo)
 {
     this._udpPeer = udpPeer;
 }
 /// <summary>
 /// Disconnect the connected UDPClient and add its IP to the blacklist</summary>
 /// <remarks>The <paramref name="blackListEnabled"/> has to be true for the bannishment to be effective</remarks>
 public void BanClient(UDPPeer peer)
 {
     udps.BanClient(peer);
 }
 /// <summary>
 /// Disconnect the connected UDPPeer</summary>
 public void KickClient(UDPPeer peer)
 {
     udps.KickClient(peer);
 }
 /// <summary>
 /// Send data through an UDPChannel to a distant user and returns an <see cref="UDPDataInfo"/> object.</summary>
 /// <param name='channelName'>The name of the channel you want to send your message through.</param>
 /// <c>It must be registered on this instance, if a channel with that name can't be found the method will throw an exception!</c>
 /// <remarks>You can check if the name is registered by calling <see cref="GetChannelByName"/></remarks>
 /// <param name="udpData">A literal object that contains the data to send</param>
 /// <param name="peer">A connected UDPPeer</param>
 public UDPDataInfo SendToClient(string channelName, object udpData, UDPPeer peer)
 {
     return(udps.SendToClient(channelName, udpData, peer));
 }