Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.IO;
|
---|
4 | using System.Net;
|
---|
5 | using System.Net.Sockets;
|
---|
6 | using System.Reflection;
|
---|
7 | using System.Threading;
|
---|
8 | using UnityEngine;
|
---|
9 |
|
---|
10 | namespace AllocsFixes.NetConnections
|
---|
11 | {
|
---|
12 | public class NetTelnetServer
|
---|
13 | {
|
---|
14 | private static List<IServer> servers = new List<IServer> ();
|
---|
15 |
|
---|
16 | public static void init (int port)
|
---|
17 | {
|
---|
18 | try {
|
---|
19 | Log.Out ("[7dtd-server-fixes by Alloc] Version: " + Assembly.GetExecutingAssembly ().GetName ().Version);
|
---|
20 | servers.Add (new Servers.Telnet.Telnet (port));
|
---|
21 |
|
---|
22 | int webPort = GamePrefs.GetInt (EnumGamePrefs.ControlPanelPort);
|
---|
23 | if (GamePrefs.GetBool (EnumGamePrefs.ControlPanelEnabled) && webPort > 0 && webPort < 65534) {
|
---|
24 | if (Directory.Exists (Application.dataPath + "/../webserver")) {
|
---|
25 | servers.Add (new Servers.Web.Web (webPort + 2));
|
---|
26 | }
|
---|
27 | }
|
---|
28 | } catch (Exception e) {
|
---|
29 | Log.Out ("Error in NetTelnetServer.init: " + e);
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | public static void SetConsole (ConsoleSdtd console)
|
---|
34 | {
|
---|
35 | }
|
---|
36 |
|
---|
37 | public static void Disconnect ()
|
---|
38 | {
|
---|
39 | foreach (IServer s in servers)
|
---|
40 | s.Disconnect ();
|
---|
41 | }
|
---|
42 |
|
---|
43 | public static void WriteToClient (string line)
|
---|
44 | {
|
---|
45 | if (line == null) {
|
---|
46 | return;
|
---|
47 | }
|
---|
48 | foreach (IServer s in servers)
|
---|
49 | s.WriteToClient (line);
|
---|
50 | }
|
---|
51 |
|
---|
52 | public static void WriteToClient_Single (string line, IConnection client)
|
---|
53 | {
|
---|
54 | if (line == null) {
|
---|
55 | return;
|
---|
56 | }
|
---|
57 | foreach (IServer s in servers)
|
---|
58 | s.WriteToClient_Single (line, client);
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.