예제 #1
0
        protected void InitDirectPlay()
        {
            // create a direct play connection
            dpc = new DPlay.Client();

            DPlay.ApplicationDescription appdesc = new DPlay.ApplicationDescription();
            appdesc.GuidApplication = new Guid("B32DD425-DB33-4f9c-972F-C68269C409F6");

            DPlay.Address dpa  = new DPlay.Address(hoststring, 895);
            DPlay.Address dpdi = new DPlay.Address();

            dpdi.ServiceProvider = DPlay.Address.ServiceProviderTcpIp;

            // Set up our event handlers
            dpc.ConnectComplete += new DPlay.ConnectCompleteEventHandler(this.ConnectComplete);

            //		dpc.ConnectComplete += new ConnectCompleteEventHandler(this.ConnectComplete);
            dpc.Receive += new DPlay.ReceiveEventHandler(this.DataReceivedMsg);
            //		dpc.SessionTerminated += new SessionTerminatedEventHandler(this.SessionLost);

            dpc.Connect(appdesc, dpa, dpdi, null, 0);
        }
예제 #2
0
        protected void StartServer()
        {
            // create a direct play server connection
            dps = new DPlay.Server();
            DPlay.ApplicationDescription appdesc = new DPlay.ApplicationDescription();
            appdesc.GuidApplication = new Guid("B32DD425-DB33-4f9c-972F-C68269C409F6");
            appdesc.MaxPlayers      = 0;
            appdesc.SessionName     = "AWarServer";
            appdesc.Flags           = DPlay.SessionFlags.ClientServer | DPlay.SessionFlags.NoDpnServer;

            DPlay.Address dpa = new DPlay.Address("192.168.1.5", 895);

            // Add our event handlers
            //		dps.PlayerDestroyed += new PlayerDestroyedEventHandler(this.DestroyPlayerMsg);
            //		dps.Receive += new DPlay.ReceiveEventHandler(this.Receive);

            //		dps.Receive+=new DPlay.ReceiveEventHandler(this.Receive);
            //		dps.IndicateConnect+=new DPlay.IndicateConnectEventHandler(this.ConnectComplete);

            dps.Receive += new DPlay.ReceiveEventHandler(this.DataReceivedMsg);

            dps.Host(appdesc, dpa);
        }