-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
105 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace GPSServer.ServerCore.Connect | ||
{ | ||
internal class Connect : IDisposable | ||
{ | ||
private Thread SessionThread = null; | ||
public string SessionIp { get; private set; } | ||
public DateTime LastActive { get; private set; } | ||
|
||
public Connect(string ip, byte[] initBuffer) | ||
{ | ||
SessionIp = ip; | ||
LastActive = DateTime.Now; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.SessionThread.Abort(); | ||
this.SessionThread = null; | ||
this.SessionIp = null; | ||
GC.Collect(); | ||
} | ||
|
||
public byte[] ProcessMessege(byte [] buffer) | ||
{ | ||
return null; | ||
} | ||
|
||
} | ||
|
||
internal class ConnectList : List<Connect> | ||
{ | ||
public ConnectList():base() | ||
{ | ||
|
||
} | ||
/// <summary> | ||
/// 尝试添加一个新链接,如果链接已经存在则返回已存在的链接 | ||
/// </summary> | ||
/// <param name="ip">链接的IP地址和端口</param> | ||
/// <param name="initBuffer">识别数据流</param> | ||
/// <returns>一个链接</returns> | ||
public Connect AddConnect(string ip, byte[] initBuffer) | ||
{ | ||
foreach (var connect in this) | ||
{ | ||
if (ip == connect.SessionIp) | ||
{ | ||
return connect; | ||
} | ||
} | ||
var newConnect = new Connect(ip, initBuffer); | ||
this.Add(newConnect); | ||
return newConnect; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters