AddonManager.IPCTalk.OfflineServerTalk.initialize C# (CSharp) Метод

initialize() публичный Метод

public initialize ( Int32 port ) : void
port System.Int32
Результат void
        public override void initialize(Int32 port)
        {
            log.InfoFormat("Initializing a new OfflineServerTalk with the target port {0}.", port);
            this.port = port;

            cts = new CancellationTokenSource();
            ct = cts.Token;

            client = new TcpClient("127.0.0.1", port);
            stream = client.GetStream();
            client.Client.NoDelay = true;
            client.NoDelay = true;

            isInitialized = true;

            log.Info("Initialized with an S<->C connection.");
            listenLoop();
        }

Usage Example

Пример #1
0
        public MainForm(Boolean isFirstRun = false, String installAddonPath = null, Boolean setupIPCTalk = false, Int32 port = -1)
        {
            Logger.Setup();

            #region Culture Independency
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
            Properties.Resources.Culture = new CultureInfo("en-GB");
            log.Info("Culture independency achieved.");
            #endregion

            Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);
            InitializeComponent();

            offlineServerTalk = new OfflineServerTalk();

            addonProject = new AddonProject();

            htmlPanel = new HtmlPanel();
            htmlPanel.AutoSize = false;
            htmlPanel.BorderStyle = BorderStyle.Fixed3D;
            htmlPanel.Location = new Point(186, 38);
            htmlPanel.Size = new Size(210, 299);
            htmlPanel.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            installAddonGroupBox.Controls.Add(htmlPanel);

            avalonEditProxyAccent.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML");
            avalonEditProxyTheme.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML");
            avalonEditProxyLanguage.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML");
            avalonEditProxyMemoryPatch.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#");

            avalonEditProxyAccent.textEditor.Text = AddonProject.Accent.defaultAccentXaml;
            avalonEditProxyTheme.textEditor.Text = AddonProject.Theme.defaultThemeXaml;
            avalonEditProxyLanguage.textEditor.Text = AddonProject.Language.defaultLanguageFileText;

            if (!String.IsNullOrWhiteSpace(installAddonPath))
            {
                log.Info("/installAddon was specified, executing run-once installation.");
                // handle auto install
            }
            else
            {
                if (isFirstRun)
                {
                    if (setupIPCTalk && port != -1)
                        offlineServerTalk.initialize(port);

                    BeginInvoke(new MethodInvoker(delegate
                    {
                        Hide();
                        FirstRunForm frForm = new FirstRunForm(this);
                        frForm.Show();
                    }));
                }
            }
        }