示例#1
0
        // TO DO: Better error reporting on this method.
        public void Shutdown()
        {
            if (Client != null)
            {
                try {
                    lock (ShutdownConnectionLock) {
                        if (NetworkStream != null)
                        {
                            NetworkStream.Close();
                            NetworkStream.Dispose();
                            NetworkStream = null;
                        }

                        Client.Close();
                        Client = null;

                        if (ConnectionClosed != null)
                        {
                            FrostbiteConnection.RaiseEvent(ConnectionClosed.GetInvocationList(), this);
                        }
                    }
                }
                catch (SocketException) {
                    // TO DO: Error reporting, possibly in a log file.
                }
                catch (Exception e) {
                    FrostbiteConnection.LogError("FrostbiteLayerConnection.Shutdown", "catch (Exception e)", e);
                }
            }
        }
示例#2
0
        public void ShutdownLayerListener()
        {
            if (this.m_tclLayerListener != null)
            {
                try {
                    PRoConLayerClient[] cplcShutdownClients = new PRoConLayerClient[this.LayerClients.Count];
                    this.LayerClients.CopyTo(cplcShutdownClients, 0);

                    foreach (PRoConLayerClient cplcShutdownClient in cplcShutdownClients)
                    {
                        cplcShutdownClient.OnShutdown();
                        cplcShutdownClient.Shutdown();
                    }

                    //if (this.m_tclLayerListener != null) {
                    this.m_tclLayerListener.Stop();
                    this.m_tclLayerListener = null;
                    //}
                }
                catch (Exception) { }

                if (this.LayerOffline != null)
                {
                    FrostbiteConnection.RaiseEvent(this.LayerOffline.GetInvocationList());
                }
            }
            //this.OnLayerServerOffline();
        }
示例#3
0
        // TO DO: Better error reporting on this method.
        public void Shutdown()
        {
            try {
                if (this.ConnectionClosed != null)
                {
                    FrostbiteConnection.RaiseEvent(this.ConnectionClosed.GetInvocationList(), this);
                }

                if (this.m_tcpConnection != null)
                {
                    lock (new object()) {
                        if (this.m_tcpStream != null)
                        {
                            this.m_tcpStream.Close();
                            this.m_tcpStream.Dispose();
                            this.m_tcpStream = null;
                        }

                        if (this.m_tcpConnection != null)
                        {
                            this.m_tcpConnection.Close();
                            this.m_tcpConnection = null;
                        }
                    }
                }
            }
            catch (SocketException) {
                // TO DO: Error reporting, possibly in a log file.
            }
            catch (Exception) {
            }
        }
示例#4
0
        public void StartLayerListener()
        {
            try {
                IPAddress ipBinding = this.ResolveHostName(this.BindingAddress);

                this.m_tclLayerListener = new TcpListener(ipBinding, this.ListeningPort);

                this.m_tclLayerListener.Start();

                if (this.LayerOnline != null)
                {
                    FrostbiteConnection.RaiseEvent(this.LayerOnline.GetInvocationList());
                }

                //this.OnLayerServerOnline();

                this.m_tclLayerListener.BeginAcceptTcpClient(this.m_asyncAcceptCallback, this);
            }
            catch (SocketException skeError) {
                if (this.LayerSocketError != null)
                {
                    FrostbiteConnection.RaiseEvent(this.LayerSocketError.GetInvocationList(), skeError);
                }

                this.ShutdownLayerListener();
                //this.OnLayerServerSocketError(skeError);
            }
        }
示例#5
0
 protected virtual void DispatchSquadIsPrivateRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
 {
     if (this.RequestPacketSquadIsPrivateReceived != null)
     {
         FrostbiteConnection.RaiseEvent(this.RequestPacketSquadIsPrivateReceived.GetInvocationList(), this, cpRecievedPacket);
     }
 }
示例#6
0
 protected virtual void DispatchHelpRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
 {
     if (this.RequestHelp != null)
     {
         FrostbiteConnection.RaiseEvent(this.RequestHelp.GetInvocationList(), this, cpRecievedPacket);
     }
 }
示例#7
0
 protected virtual void DispatchAdminShutDownRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
 {
     if (this.RequestPacketAdminShutdown != null)
     {
         FrostbiteConnection.RaiseEvent(this.RequestPacketAdminShutdown.GetInvocationList(), this, cpRecievedPacket);
     }
 }
示例#8
0
 private void m_connection_ConnectionClosed(FrostbiteLayerConnection sender)
 {
     if (this.ConnectionClosed != null)
     {
         FrostbiteConnection.RaiseEvent(this.ConnectionClosed.GetInvocationList(), this);
     }
 }
示例#9
0
        public void DownloadInstallPackage(string uid, bool localInstall)
        {
            if (this.CanDownloadPackage(uid) == true)
            {
                if (this.PackageBeginningDownload != null)
                {
                    FrostbiteConnection.RaiseEvent(this.PackageBeginningDownload.GetInvocationList(), this, this.RemotePackages[uid]);
                }

                this.RegisterEvents(this.RemotePackages[uid]);

                if (localInstall == true)
                {
                    switch (this.RemotePackages[uid].PackageType)
                    {
                    case PackageType.Plugin:
                        //this.RegisterEvents(this.RemotePackages[uid]);
                        this.RemotePackages[uid].DownloadPackage(PackageManager.DIRECTORY_UPDATES);
                        break;

                    case PackageType.Mappack:
                        this.RemotePackages[uid].DownloadPackage("");
                        break;
                    }
                }
                else
                {
                    // Extract to procon folder
                    this.RemotePackages[uid].DownloadPackage("");
                }
            }
        }
示例#10
0
        private void m_prcClient_PlayerKilled(PRoConClient sender, Kill kKillerVictimDetails)
        {
            float trespassArea = 0.0F;

            foreach (MapZoneDrawing zone in new List <MapZoneDrawing>(MapZones))
            {
                if (System.String.Compare(CurrentMapFileName, zone.LevelFileName, System.StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if ((trespassArea = zone.TrespassArea(kKillerVictimDetails.KillerLocation, 14.14F)) > 0.0F)
                    {
                        if (MapZoneTrespassed != null)
                        {
                            FrostbiteConnection.RaiseEvent(MapZoneTrespassed.GetInvocationList(), kKillerVictimDetails.Killer, ZoneAction.Kill, new MapZone(zone.UID, zone.LevelFileName, zone.Tags.ToString(), zone.ZonePolygon, true), kKillerVictimDetails.KillerLocation, trespassArea, kKillerVictimDetails);
                        }
                    }

                    if ((trespassArea = zone.TrespassArea(kKillerVictimDetails.VictimLocation, 14.14F)) > 0.0F)
                    {
                        if (MapZoneTrespassed != null)
                        {
                            FrostbiteConnection.RaiseEvent(MapZoneTrespassed.GetInvocationList(), kKillerVictimDetails.Victim, ZoneAction.Death, new MapZone(zone.UID, zone.LevelFileName, zone.Tags.ToString(), zone.ZonePolygon, true), kKillerVictimDetails.VictimLocation, trespassArea, kKillerVictimDetails);
                        }
                    }
                }
            }
        }
示例#11
0
        private static void ListenIncommingLayerConnections(IAsyncResult ar)
        {
            PRoConLayer plLayer = (PRoConLayer)ar.AsyncState;

            if (plLayer.m_tclLayerListener != null)
            {
                try {
                    TcpClient tcpNewConnection = plLayer.m_tclLayerListener.EndAcceptTcpClient(ar);

                    PRoConLayerClient cplcNewConnection = new PRoConLayerClient(new FrostbiteLayerConnection(tcpNewConnection), plLayer.m_praApplication, plLayer.m_prcClient);

                    plLayer.LayerClients.Add(cplcNewConnection);

                    if (plLayer.ClientConnected != null)
                    {
                        FrostbiteConnection.RaiseEvent(plLayer.ClientConnected.GetInvocationList(), cplcNewConnection);
                    }

                    plLayer.m_tclLayerListener.BeginAcceptTcpClient(plLayer.m_asyncAcceptCallback, plLayer);
                }
                catch (SocketException exception) {
                    if (plLayer.LayerSocketError != null)
                    {
                        FrostbiteConnection.RaiseEvent(plLayer.LayerSocketError.GetInvocationList(), exception);
                    }

                    plLayer.ShutdownLayerListener();

                    //cbfAccountsPanel.OnLayerServerSocketError(skeError);
                }
                catch (Exception) {
                }
            }
        }
示例#12
0
 protected virtual void DispatchUnsecureSafeListedRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
 {
     if (this.RequestPacketUnsecureSafeListedRecieved != null)
     {
         FrostbiteConnection.RaiseEvent(this.RequestPacketUnsecureSafeListedRecieved.GetInvocationList(), this, cpRecievedPacket);
     }
 }
示例#13
0
 protected virtual void DispatchAlterReservedSlotsListRequest(FrostbiteLayerConnection sender, Packet cpRecievedPacket)
 {
     if (this.RequestPacketAlterReservedSlotsListRecieved != null)
     {
         FrostbiteConnection.RaiseEvent(this.RequestPacketAlterReservedSlotsListRecieved.GetInvocationList(), this, cpRecievedPacket);
     }
 }
示例#14
0
 private void Tags_TagsEdited(ZoneTagList sender)
 {
     if (this.TagsEdited != null)
     {
         FrostbiteConnection.RaiseEvent(this.TagsEdited.GetInvocationList(), this);
     }
 }
示例#15
0
 private void item_TagsEdited(MapZoneDrawing sender)
 {
     if (this.MapZoneChanged != null)
     {
         FrostbiteConnection.RaiseEvent(this.MapZoneChanged.GetInvocationList(), sender);
     }
 }
示例#16
0
 private void GameConfigInfo()
 {
     this.m_blGameConfigHint = true;
     if (this.GameConfigUpdated != null)
     {
         FrostbiteConnection.RaiseEvent(this.GameConfigUpdated.GetInvocationList());
     }
 }
示例#17
0
        //private void focus_DownloadProgressUpdate(Package sender, CDownloadFile file) {
        //    this.UnregisterEvents(sender);
        //}

        private void focus_DownloadComplete(Package sender, CDownloadFile file)
        {
            //this.UnregisterEvents(sender);

            if (this.PackageDownloaded != null)
            {
                FrostbiteConnection.RaiseEvent(this.PackageDownloaded.GetInvocationList(), this, sender);
            }
        }
示例#18
0
        private void focus_PackageEndUnzip(Package sender)
        {
            this.UnregisterEvents(sender);

            if (this.PackageAwaitingRestart != null)
            {
                FrostbiteConnection.RaiseEvent(this.PackageAwaitingRestart.GetInvocationList(), this, sender);
            }
        }
示例#19
0
        protected override void SetItem(int index, CPlayerInfo item)
        {
            if (this.PlayerRemoved != null)
            {
                FrostbiteConnection.RaiseEvent(this.PlayerRemoved.GetInvocationList(), item);
            }

            base.SetItem(index, item);
        }
示例#20
0
        private void Write(DateTime dtLoggedTime, string strText)
        {
            WriteLogLine(String.Format("[{0}] {1}", dtLoggedTime.ToString("HH:mm:ss"), strText.Replace("{", "{{").Replace("}", "}}")));

            if (WriteConsole != null)
            {
                FrostbiteConnection.RaiseEvent(WriteConsole.GetInvocationList(), dtLoggedTime, strText);
            }
        }
示例#21
0
        protected override void InsertItem(int index, Account item)
        {
            base.InsertItem(index, item);

            if (this.AccountAdded != null)
            {
                FrostbiteConnection.RaiseEvent(this.AccountAdded.GetInvocationList(), item);
            }
        }
示例#22
0
        protected override void RemoveItem(int index)
        {
            if (this.LayerClientDisconnected != null)
            {
                FrostbiteConnection.RaiseEvent(this.LayerClientDisconnected.GetInvocationList(), this[index]);
            }

            base.RemoveItem(index);
        }
示例#23
0
        private void focus_DownloadError(Package sender, CDownloadFile file)
        {
            this.UnregisterEvents(sender);

            if (this.PackageDownloadFail != null)
            {
                FrostbiteConnection.RaiseEvent(this.PackageDownloadFail.GetInvocationList(), this, sender);
            }
        }
示例#24
0
        protected override void RemoveItem(int index)
        {
            if (AccountRemoved != null)
            {
                FrostbiteConnection.RaiseEvent(AccountRemoved.GetInvocationList(), this[index]);
            }

            base.RemoveItem(index);
        }
示例#25
0
        protected override void InsertItem(int index, PRoConClient item)
        {
            if (this.ConnectionAdded != null)
            {
                FrostbiteConnection.RaiseEvent(this.ConnectionAdded.GetInvocationList(), item);
            }

            base.InsertItem(index, item);
        }
示例#26
0
        /// <summary>
        ///     This public method is used whenever the chat console has been written to via
        ///     the procon.protected.chat.write command (basically plugin output)
        /// </summary>
        /// <param name="strText"></param>
        public void WriteViaCommand(string strText)
        {
            Write(DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime(), strText);

            if (WriteConsoleViaCommand != null)
            {
                FrostbiteConnection.RaiseEvent(WriteConsoleViaCommand.GetInvocationList(), DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime(), strText);
            }
        }
示例#27
0
        protected override void SetItem(int index, Account item)
        {
            if (this.AccountChanged != null)
            {
                FrostbiteConnection.RaiseEvent(this.AccountChanged.GetInvocationList(), item);
            }

            base.SetItem(index, item);
        }
示例#28
0
        public void SetPrivileges(CPrivileges cpUpdatedPrivileges)
        {
            Privileges = cpUpdatedPrivileges;

            if (AccountPrivilegesChanged != null)
            {
                FrostbiteConnection.RaiseEvent(AccountPrivilegesChanged.GetInvocationList(), this);
            }
        }
示例#29
0
        protected override void SetItem(int index, PRoConLayerClient item)
        {
            if (this.LayerClientAltered != null)
            {
                FrostbiteConnection.RaiseEvent(this.LayerClientAltered.GetInvocationList(), item);
            }

            base.SetItem(index, item);
        }
示例#30
0
        protected override void InsertItem(int index, CLocalization item)
        {
            base.InsertItem(index, item);

            if (this.LanguageAdded != null)
            {
                FrostbiteConnection.RaiseEvent(this.LanguageAdded.GetInvocationList(), item);
            }
        }