The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C# Code
Posted by: fs_session | February 18, 2010 @ 9:56pm
C# Code
[
Download
]
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; namespace LoginServer { public class SessionCmp : ActiveComponent { int maxSlots; public class Session { public Socket Socket; public byte[] Buffer; public Socket sendSocket; public Socket listensocket; public SocketInformation info; public Session() { Buffer = new byte[Int32.Parse((string)Components.Settings().data["net"]["buffer_size"])]; sendSocket = listensocket; } public void Send(byte[] buffer) { Socket list = new Socket(info); // whatever. sendSocket = listensocket; list.Send(buffer); } } public Session[] Sessions; public override void Init() { maxSlots = Int32.Parse((string)Components.Settings().data["net"]["max_connections"]); Sessions = new Session[maxSlots]; for (int i = 0; i < maxSlots; i++) { Sessions[i] = null; } Console.WriteLine("SessionCMP/Init(): Session manager has been created"); } public override void Load() { } public override void Start() { } public override void Shutdown() { } public override void Update() { // some continuity checking can go here later. } public int GetSlot() { for (int i = 0; i < maxSlots; i++) { if (Sessions[i] == null) { return i; } } return -1; } public void CreateSession(int ID, Socket listensocket) { Sessions[ID] = new Session(); } public void MarkForDestroy(int ID) { // THIS FUNCTION IS BAD! IT DOESNT HAVE ANY MERCY FOR INTERNET DISCONNECTS. REWRITE URGENTLY. Sessions[ID] = null; } } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.29 / 8
56 Votes
http://codebin.yi.org/510
page generated in 0.01 seconds