|
You last visited: Today at 17:00
Advertisement
[Brainstorm] Seperate Game/Npc etc Servers
Discussion on [Brainstorm] Seperate Game/Npc etc Servers within the CO2 Private Server forum part of the Conquer Online 2 category.
06/09/2010, 09:27
|
#1
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
[Brainstorm] Seperate Game/Npc etc Servers
Hey guys, I've been planing on having separate programs for the Game/Npc etc servers, so I've just been thinking of the best way to about implementing it.
It's for my own scratch source so don't worry about giving source-specific examples.
But yeah, if you got any ideas lemme hear em =P
|
|
|
06/09/2010, 09:48
|
#2
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Well for login>game you won't need much communication so a simple socket system can work. If you were doing something that required more data to be sent (such as a logic server, npc server, dmap server or anything) then namcode pipes are the way to go due to their speed and efficiency.
Sadly i haven't used named pipes enough to be able to give advice. Most i've done so far is read up on them and use some example code.
|
|
|
06/09/2010, 10:05
|
#3
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by pro4never
Well for login>game you won't need much communication so a simple socket system can work. If you were doing something that required more data to be sent (such as a logic server, npc server, dmap server or anything) then namcode pipes are the way to go due to their speed and efficiency.
Sadly i haven't used named pipes enough to be able to give advice. Most i've done so far is read up on them and use some example code.
|
Yeah Login->Game is no problem.
Sweet, I'll have to check them out, thanks.
|
|
|
06/09/2010, 14:42
|
#4
|
elite*gold: 0
Join Date: Nov 2009
Posts: 754
Received Thanks: 544
|
Quote:
Originally Posted by kinshi88
Yeah Login->Game is no problem.
Sweet, I'll have to check them out, thanks.
|
PipeServer wrapper
Code:
public delegate void PipeReceives(PipeClient Client, byte[] Arguments);
public class PipeServer
{
private Thread readThread, EnableThread;
private SafeFileHandle cHandle;
public event PipeReceives PipeReceived;
public string Name;
private uint BufferSize = 4096;
public PipeServer()
{
EnableThread = new Thread(new ThreadStart(Run));
}
public void Enable(string Input)
{
this.Name = Input;
EnableThread.Start();
}
private void Run()
{
while (true)
{
this.cHandle = Native.CreateNamedPipe(
@"\\.\pipe\"+Name+"",
Native.DUPLEX | Native.FILE_FLAG_OVERLAPPED,
0,
255,
this.BufferSize,
this.BufferSize,
0,
IntPtr.Zero);
switch (this.cHandle.IsInvalid)
{
case true: return;
case false:
switch (Native.ConnectNamedPipe(this.cHandle, IntPtr.Zero))
{
case 0: return;
default:
PipeClient Instance = new PipeClient();
Instance.sHandle = this.cHandle;
Instance.ID = CPX.LastConnected++;
lock (CPX.ClientPool)
CPX.ClientPool.Add(Instance.ID, Instance);
this.readThread = new Thread(new ParameterizedThreadStart(Accept));
this.readThread.Start(Instance);
break;
}
break;
}
}
}
private void Accept(object Param)
{
PipeClient Instance = (Param as PipeClient);
Instance.fStream = new FileStream(Instance.sHandle, FileAccess.ReadWrite, 4096, true);
int BytesReadedSoFar;
byte[] Buffer = new byte[this.BufferSize];
while (true)
{
BytesReadedSoFar = Instance.fStream.Read(Buffer, 0, (int)this.BufferSize);
switch (BytesReadedSoFar)
{
case 0: return;
default:
if (this.PipeReceived != null)
this.PipeReceived.Invoke(Instance, Buffer);
break;
}
}
Instance.fStream.Close();
Instance.sHandle.Close();
lock (CPX.ClientPool)
CPX.ClientPool.Remove(Instance.ID);
}
}
Pinvoke functions:
Code:
[DllImport("kernel32.dll", SetLastError = true)]
public static extern SafeFileHandle CreateNamedPipe(
String pipeName,
uint dwOpenMode,
uint dwPipeMode,
uint nMaxInstances,
uint nOutBufferSize,
uint nInBufferSize,
uint nDefaultTimeOut,
IntPtr lpSecurityAttributes);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern int ConnectNamedPipe(
SafeFileHandle hNamedPipe,
IntPtr lpOverlapped);
public const uint DUPLEX = (0x00000003);
public const uint GENERIC_READ = (0x80000000);
public const uint GENERIC_WRITE = (0x40000000);
public const uint OPEN_EXISTING = 3;
public const uint FILE_FLAG_OVERLAPPED = (0x40000000);
//Networking
[DllImport("msvcrt.dll")]
public static extern void* memcpy(void* dest, void* src, int size);
public static void MemCopy(byte[] Dest, byte[] Src, int Size)
{
fixed (byte* src = Src, dst = Dest)
memcpy(dst, src, Size);
}
public static void MemCopy(byte[] Dest, int DestOffset, byte[] Src, int Size)
{
fixed (byte* src = Src, dst = Dest)
memcpy(dst + DestOffset, src, Size);
}
public static void MemCopy(byte[] Dest, int DestOffset, byte[] Src, int SourceOffset, int Size)
{
fixed (byte* src = Src, dst = Dest)
memcpy(dst + DestOffset, src + SourceOffset, Size);
}
public static void MemCopy(byte[] Dest, byte[] Src, int SourceOffset, int Size)
{
fixed (byte* src = Src, dst = Dest)
memcpy(dst, src + SourceOffset, Size);
}
PipeClient wrapper
Code:
public class PipeClient
{
public SafeFileHandle sHandle;
public FileStream fStream;
public uint ID;
public void AppendBytes(byte[] Args)
{
lock (this.fStream)
{
this.fStream.Write(Args, 0, Args.Length);
this.fStream.Flush();
}
}
}
Put it together for you as example.
|
|
|
06/09/2010, 16:50
|
#5
|
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
|
Named pipes offer the "benefit" of relying on physical memory instead of your network, but sometimes it's necessary to be able to extend beyond that boundary. The .NET Remoting Infrastructure seems like a great solution to your inter-process communication problem-since the architecture was built to answer specifically that issue, and I would really like to see you use it in your projects.
|
|
|
06/10/2010, 00:36
|
#6
|
elite*gold: 0
Join Date: Apr 2006
Posts: 55
Received Thanks: 12
|
Quote:
Originally Posted by kinshi88
Hey guys, I've been planing on having separate programs for the Game/Npc etc servers, so I've just been thinking of the best way to about implementing it.
It's for my own scratch source so don't worry about giving source-specific examples.
But yeah, if you got any ideas lemme hear em =P
|
Honestly Kinshi get ahold of Jack aka Korvacs he did a server in front of me that was a auth/game server that communicated and transferred date in between each other extremely well and very stable. He would be able to give ya some ideas.
|
|
|
06/10/2010, 00:43
|
#7
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by joshvette001
Honestly Kinshi get ahold of Jack aka Korvacs he did a server in front of me that was a auth/game server that communicated and transferred date in between each other extremely well and very stable. He would be able to give ya some ideas.
|
Auth/Game is (again) no problem. Since the Client connects to the auth, then the game.
But yeah, I spell all night checking out named pipes, and **** are they awesome.
How come I've never heard about these before?? =P
|
|
|
06/10/2010, 03:34
|
#8
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Quote:
Originally Posted by kinshi88
Auth/Game is (again) no problem. Since the Client connects to the auth, then the game.
But yeah, I spell all night checking out named pipes, and **** are they awesome.
How come I've never heard about these before?? =P
|
Because you didn't pm korv asking what to use lol. He's the one who told me about them... although i had seen them mentioned in some research before.
|
|
|
06/10/2010, 04:31
|
#9
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by pro4never
Because you didn't pm korv asking what to use lol. He's the one who told me about them... although i had seen them mentioned in some research before.
|
Haha, well thanks.
|
|
|
06/10/2010, 05:44
|
#10
|
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
|
I guess I'm alone with .NET Remoting then, huh?
|
|
|
06/10/2010, 06:39
|
#11
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by s.bat
I guess I'm alone with .NET Remoting then, huh?
|
Haha aww.
I'll check it out dude =P
|
|
|
06/10/2010, 09:12
|
#12
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by s.bat
I guess I'm alone with .NET Remoting then, huh?
|
Well, if no one else has used it before, and no one has posted any information about it, i hardly think people are going to just decide to use it based on one post with no explanation of how it works or what its advantages are over other methods.
Also Named Pipes are not limited to your local machine they can be used across a local network, so there is no limitation in that way.
|
|
|
06/10/2010, 16:09
|
#13
|
elite*gold: 0
Join Date: Nov 2009
Posts: 754
Received Thanks: 544
|
Quote:
Originally Posted by Korvacs
Well, if no one else has used it before, and no one has posted any information about it, i hardly think people are going to just decide to use it based on one post with no explanation of how it works or what its advantages are over other methods.
Also Named Pipes are not limited to your local machine they can be used across a local network, so there is no limitation in that way.
|
*cough* Some things shouldn't be released to this forum.
|
|
|
06/10/2010, 17:39
|
#14
|
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
|
Quote:
Originally Posted by ImmuneOne
*cough* Some things shouldn't be released to this forum.
|
I suppose that's true to an extent, but in my case, there is a lot of valuable information already accessible on the internet that could easily supersede my attempt at explicating .NET Remoting.
As for the named pipes being used over a network, I didn't research it carefully enough, and I apologize for that.
Also, has anyone taken a look at the  ? I'm asking because ImmuneOne chose to use P/Invoke instead.
|
|
|
06/10/2010, 17:57
|
#15
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by s.bat
I suppose that's true to an extent, but in my case, there is a lot of valuable information already accessible on the internet that could easily supersede my attempt at explicating .NET Remoting.
As for the named pipes being used over a network, I didn't research it carefully enough, and I apologize for that.
Also, has anyone taken a look at the  ? I'm asking because ImmuneOne chose to use P/Invoke instead.
|
Personally i use the framework's classes and methods for named pipes, works like a charm.
|
|
|
 |
|
Similar Threads
|
[Brainstorm]CabalNA LiveDebuggers
10/09/2009 - Cabal Online - 2 Replies
Well CabalNA still hasn't got the AoS B2F update yet but I want to figure out how to do things BEFORE this update happens so I can reapply them after :) but so far I get stuck at live debugging the unpacked cabalmain.exe I have. Here's a list of problems
1. The unpacked cabalmain CRASHES every 2 min of being logged on (with twinr it just throws me to login page saying iv'e been DCed but not error code) without twinr I DC then xtrap shows up and crashes cabal. I've tried finding the sockets...
|
[Brainstorm]Spanish Help?... and to all CabalNA unapckers
10/01/2009 - Cabal Online - 22 Replies
http://i35.tinypic.com/4iecnt.jpg http://i38.tinypic.com/3447a8n.jpg
Well I was browsing through the very useful olly folder nova uploaded and found this so I decided to test it on cabalmain.exe and it tells something dif then BinDiE!!! It says it's packed with a higher themida then we all previously thought AND the Xtreme packer thing.... (never seen that before) soooo any ideas on what to do now? Just a thread for us to share ideas since all of us can't be working on this 24/7 maybe some...
|
Okay so...brainstorm with me here.
05/23/2008 - RF Online - 7 Replies
post deleted for misunderstandings
|
All times are GMT +1. The time now is 17:01.
|
|