Register for your free account! | Forgot your password?

Go Back   elitepvpers > Other Online Games > Browsergames > DarkOrbit
You last visited: Today at 01:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Tutorial] Netty Based Server

Discussion on [Tutorial] Netty Based Server within the DarkOrbit forum part of the Browsergames category.

Reply
 
Old 08/14/2016, 20:46   #31
 
-=Flavio=-'s Avatar
 
elite*gold: 0
Join Date: Jul 2012
Posts: 604
Received Thanks: 259
haha I had not noticed it :P anyway I will test soon
-=Flavio=- is offline  
Old 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();
        }
    }
}
mustafagrlyn is offline  
Thanks
1 User
Old 08/15/2016, 00:50   #33
 
ItsTequila's Avatar
 
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.
ItsTequila is offline  
Old 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:
olitis1 is offline  
Old 08/15/2016, 22:41   #35


 
Requi's Avatar
 
elite*gold: 3800
The Black Market: 244/0/0
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
Quote:
Originally Posted by olitis1 View Post
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:
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.
Requi is offline  
Old 08/15/2016, 23:09   #36
 
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
Quote:
Originally Posted by Requi View Post
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->
olitis1 is offline  
Old 08/16/2016, 11:35   #37


 
Requi's Avatar
 
elite*gold: 3800
The Black Market: 244/0/0
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
Quote:
Originally Posted by olitis1 View Post
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.
Requi is offline  
Old 08/16/2016, 12:29   #38
 
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
Quote:
Originally Posted by Requi View Post
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.
olitis1 is offline  
Old 08/16/2016, 12:30   #39


 
Requi's Avatar
 
elite*gold: 3800
The Black Market: 244/0/0
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
Quote:
Originally Posted by olitis1 View Post
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.
Requi is offline  
Old 08/16/2016, 12:32   #40
 
elite*gold: 0
Join Date: Apr 2012
Posts: 182
Received Thanks: 128
Quote:
Originally Posted by Requi View Post
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)
olitis1 is offline  
Old 08/16/2016, 12:37   #41


 
Requi's Avatar
 
elite*gold: 3800
The Black Market: 244/0/0
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
Quote:
Originally Posted by olitis1 View Post
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.
Requi is offline  
Old 08/16/2016, 12:39   #42
 
elite*gold: 46
Join Date: Oct 2010
Posts: 782
Received Thanks: 525
Quote:
Originally Posted by Requi View Post
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).
th0rex is offline  
Old 08/16/2016, 12:40   #43


 
Requi's Avatar
 
elite*gold: 3800
The Black Market: 244/0/0
Join Date: Dec 2012
Posts: 13,039
Received Thanks: 8,243
Quote:
Originally Posted by C0untLizzi View Post
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.
Requi is offline  
Old 08/17/2016, 05:15   #44
 
ItsTequila's Avatar
 
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.
ItsTequila is offline  
Old 08/17/2016, 08:45   #45
 
manulaiko3.0's Avatar
 
elite*gold: 0
Join Date: May 2014
Posts: 662
Received Thanks: 1,154
Quote:
Originally Posted by NUMANDERBUHMAN View Post
@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...
manulaiko3.0 is offline  
Thanks
2 Users
Reply


Similar Threads 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.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.