|
You last visited: Today at 01:46
Advertisement
[Tutorial] Netty Based Server
Discussion on [Tutorial] Netty Based Server within the DarkOrbit forum part of the Browsergames category.
08/14/2016, 20:46
|
#31
|
elite*gold: 0
Join Date: Jul 2012
Posts: 604
Received Thanks: 259
|
haha I had not noticed it :P anyway I will test soon
|
|
|
08/14/2016, 23:25
|
#32
|
elite*gold: 0
Join Date: Jun 2014
Posts: 4
Received Thanks: 4
|
Hello
Packet.cs -> Send(Commands.StringPacket("")); ^_^
I Love You Shock <3
Netty Emulator: Shock[DEV]
Edited and Updated: ΉΛDΣS_PЯO[DΣV]
NOTE: This emulator (NeetyBase) created by Shock and edited by ΉΛDΣS_PЯO[DΣV].
Code:
using NettyBase.Net
namespace Server
{
static class Commands
{
public static byte[] StringPacket(string n)
{
ByteArray enc = new ByteArray(29052);
enc.UTF(n);
return enc.ToByteArray();
}
}
}
|
|
|
08/15/2016, 00:50
|
#33
|
elite*gold: 0
Join Date: Jun 2015
Posts: 647
Received Thanks: 954
|
To the one who is trying his emulator, I'm very sorry maps.php got fixed.
|
|
|
08/15/2016, 20:33
|
#34
|
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
|
You should use locks to make sure that your code won't be doing ugly things when an action is called simultaneously and the action before hasn't finished.
For example in Utils.Out.cs it should be like:
Code:
using System;
namespace NettyBase
{
class Out
{
private static object WriteLock = new object();
/// <summary>
/// That should replace the Console.WriteLine with a little more ordered version.
/// </summary>
/// <param name="message">That's where the input text goes</param>
/// <param name="header">This parameter is optional and it stands for the [header] before the text</param>
/// <param name="color">This parameter is optional and it is chosing the color you would like the text to be</param>
public static void WriteLine(string message, string header = "", ConsoleColor color = ConsoleColor.Gray)
{
lock(WriteLock)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("[" + DateTime.Now + "]");
if (header != "")
{
Console.Write("[");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write(header);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("]");
}
Console.Write(" - ");
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
}
|
|
|
08/15/2016, 22:41
|
#35
|
elite*gold: 3800
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
|
Quote:
Originally Posted by olitis1
You should use locks to make sure that your code won't be doing ugly things when an action is called simultaneously and the action before hasn't finished.
For example in Utils.Out.cs it should be like:
Code:
using System;
namespace NettyBase
{
class Out
{
private static object WriteLock = new object();
/// <summary>
/// That should replace the Console.WriteLine with a little more ordered version.
/// </summary>
/// <param name="message">That's where the input text goes</param>
/// <param name="header">This parameter is optional and it stands for the [header] before the text</param>
/// <param name="color">This parameter is optional and it is chosing the color you would like the text to be</param>
public static void WriteLine(string message, string header = "", ConsoleColor color = ConsoleColor.Gray)
{
lock(WriteLock)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("[" + DateTime.Now + "]");
if (header != "")
{
Console.Write("[");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write(header);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("]");
}
Console.Write(" - ");
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
}
|
As far as I know, locks are only necessary when using lists/dictionaries/arrays which could be changed while they are being used. I might be wrong though.
|
|
|
08/15/2016, 23:09
|
#36
|
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
|
Quote:
Originally Posted by Requi
As far as I know, locks are only necessary when using lists/dictionaries/arrays which could be changed while they are being used. I might be wrong though.
|
Locks can be used when you know that an action could take some time (to write some lines) and it can be called concurrently.
While the action is performing some text color changes and writing, the action is again called.
With a lock, you make sure that the lines will be full written (thread-safe).
That's a possible scenario:
Without a Lock -> With a Lock->
|
|
|
08/16/2016, 11:35
|
#37
|
elite*gold: 3800
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
|
Quote:
Originally Posted by olitis1
Locks can be used when you know that an action could take some time (to write some lines) and it can be called concurrently.
While the action is performing some text color changes and writing, the action is again called.
With a lock, you make sure that the lines will be full written (thread-safe).
That's a possible scenario:
Without a Lock -> With a Lock->
|
You gotta do something horribly wrong that this happens. I've never had it happened that the streamio got corrupted.
|
|
|
08/16/2016, 12:29
|
#38
|
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
|
Quote:
Originally Posted by Requi
You gotta do something horribly wrong that this happens. I've never had it happened that the streamio got corrupted.
|
It's not writting 1 time, it's writting 3 times (to change colour and add header and that...) for each single line.
|
|
|
08/16/2016, 12:30
|
#39
|
elite*gold: 3800
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
|
Quote:
Originally Posted by olitis1
It's not writting 1 time, it's writting 3 times for each single line.
|
then it would be better to concat the string and then write it, instead of abusing the stream so much.
|
|
|
08/16/2016, 12:32
|
#40
|
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
|
Quote:
Originally Posted by Requi
then it would be better to concat the string and then write it, instead of abusing the stream so much.
|
You can't change the colour in the same string. (or atleast I think so)
|
|
|
08/16/2016, 12:37
|
#41
|
elite*gold: 3800
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
|
Quote:
Originally Posted by olitis1
You can't change the colour in the same string. (or atleast I think so)
|
Code:
using System;
namespace NettyBase
{
class Out
{
/// <summary>
/// That should replace the Console.WriteLine with a little more ordered version.
/// </summary>
/// <param name="message">That's where the input text goes</param>
/// <param name="header">This parameter is optional and it stands for the [header] before the text</param>
/// <param name="color">This parameter is optional and it is chosing the color you would like the text to be</param>
public static void WriteLine(string message, string header = "", ConsoleColor color = ConsoleColor.Gray)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("[" + DateTime.Now + "]");
Console.ForegroundColor = ConsoleColor.DarkGray;
header = header == "" ? header : "[" + header + "]";
Console.Write(header);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(" - ");
Console.ForegroundColor = color;
Console.WriteLine(message);
//Console.ForegroundColor = ConsoleColor.Gray; // u'll reset the color at the start anyways.
}
}
}
Oh look. 2 less stream writings.
|
|
|
08/16/2016, 12:39
|
#42
|
elite*gold: 46
Join Date: Oct 2010
Posts: 782
Received Thanks: 525
|
Quote:
Originally Posted by Requi
Code:
using System;
namespace NettyBase
{
class Out
{
private static object WriteLock = new object();
/// <summary>
/// That should replace the Console.WriteLine with a little more ordered version.
/// </summary>
/// <param name="message">That's where the input text goes</param>
/// <param name="header">This parameter is optional and it stands for the [header] before the text</param>
/// <param name="color">This parameter is optional and it is chosing the color you would like the text to be</param>
public static void WriteLine(string message, string header = "", ConsoleColor color = ConsoleColor.Gray)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("[" + DateTime.Now + "]");
Console.ForegroundColor = ConsoleColor.DarkGray;
header = header == "" ? header : "[" + header + "]";
Console.Write(header);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(" - ");
Console.ForegroundColor = color;
Console.WriteLine(message);
//Console.ForegroundColor = ConsoleColor.Gray; // u'll reset the color at the start anyways.
}
}
}
Oh look. 2 less stream writings.
|
That code is still not thread safe and locks are indeed needed if your application uses more than one thread (which it will if it's a server, because single threaded servers are slow as fuck).
|
|
|
08/16/2016, 12:40
|
#43
|
elite*gold: 3800
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
|
Quote:
Originally Posted by C0untLizzi
That code is still not thread safe and locks are indeed needed if your application uses more than one thread (which it will if it's a server, because single threaded servers are slow as ****).
|
And if you want a fast server which is threadsafe then don't write every ******* bullshit in the console. Try to prevent using the console that much.
|
|
|
08/17/2016, 05:15
|
#44
|
elite*gold: 0
Join Date: Jun 2015
Posts: 647
Received Thanks: 954
|
@olitis Thank you a lot for the lock I was wondering why when I start the chat server's task it writes on top of itself.
Is anyone able to make packet / socket redirect code on PHP in order to get all the packets from the emulator and handle them there instead of inventory.php.
|
|
|
08/17/2016, 08:45
|
#45
|
elite*gold: 0
Join Date: May 2014
Posts: 662
Received Thanks: 1,154
|
Quote:
Originally Posted by NUMANDERBUHMAN
@olitis Thank you a lot for the lock I was wondering why when I start the chat server's task it writes on top of itself.
Is anyone able to make packet / socket redirect code on PHP in order to get all the packets from the emulator and handle them there instead of inventory.php.
|
But I'll move it to along this week...
|
|
|
|
|
Similar Threads
|
Speed Sro (Online) [130Cap-Coin System- (Job based) - Pvp Server - (Play2Win Server -
07/25/2014 - SRO PServer Advertising - 3 Replies
http://i.epvpimg.com/HN59f.jpg
http://i.epvpimg.com/TQNrf.jpg
http://i.epvpimg.com/HaDKd.png
•Website : Speed
http://i.epvpimg.com/HaDKd.png
•Reg Link : Speed
http://i.epvpimg.com/HaDKd.png
|
Hello, I'm looking for a card based game botting tutorial.
04/02/2014 - AutoIt - 4 Replies
Hello epvpers, I just registered and would like first of all to thank you for the opportunity to learn some coding.
Secondly, I'd like to apologize in advance if I'm breaking any forum rules that I might have not seen.
And thirdly, here is my request: I would like to know if there is any tutorials on how to make a game bot.
The particulars are that its a card based game and from what I read so far a pixel search approach its recommended. I'd like to know if there are other approaches...
|
server based on taiwan server files (give me your opinion) Fast ^_^
12/09/2013 - SRO PServer Advertising - 4 Replies
I got a TW Server files and i launched it , and fixed all bugs and problems its now 100% working
So what do u think i have to open it (PvP Or PvE) & The Cap ! But remember that there's no any bot works with it except Kbot i think btw give us your opinion !
Thanks :)
|
[C#] DarkOrbit Encoding/Decoding from Netty
05/18/2013 - DarkOrbit - 5 Replies
Hello, today i bring you how to encode and decode the packets of the new darkorbit(which uses netty).
Dictionary:
Short - 2 bytes
Int - 4 bytes
Bool - 1 byte
Str or UTF - Short Length of String + String
The structure of the packets are:
1 - Short Length of all packet
|
Ecsro Based Server 90SKILL And 90 Cap first realy oldschool server + Beginner Event
08/14/2012 - SRO PServer Advertising - 375 Replies
hey guys,
After a long downtime we are now back online would be finde to see You again
Stall Is Disabled In Gameserver so Dupe Unable To Use
Events for beginning :
20.08.2012 Have fun :)
First account Gets 200free silk
Normal Events :
|
All times are GMT +2. The time now is 01:46.
|
|