Jump to content
Dastgir

[Plugin] Map-Char Communication

Recommended Posts

Now, its time to show examples of how map-char communication can be made,

this is essential as there's no example anywhere about this, so here it is...

 

 

https://raw.githubusercontent.com/dastgir/HPM-Plugins/master/src/plugins/packet_sample.c
Above is the example of Communication between Map-Char Server

Here's Description of what All Functions does:

  • map_sendtochar: Sends Packet to the char-server
  • packet_test(Command): Sets common_value and calls map_sendtochar
  • char_receive_packet: CharServer Function to receive packets(see declaration in plugin_init)


ScreenShot:

iNxi8yq.png

Share this post


Link to post
Share on other sites

you have a typo for char_receive_packet

void char_receive_packet(int fd) {	ShowDebug("Char: CommonValue(Before parsing packet): %dn",common_value);	common_value = RFIFOL(fd, 2);	ShowDebug("Char: CommonValue(After parsing packet): %dn",common_value);	return;}
.
.

ok so ...

enum HPluginPacketHookingPoints {	hpClif_Parse,      ///< map-server (client-map)	hpChrif_Parse,     ///< map-server (char-map)	hpParse_FromMap,   ///< char-server (map-char)	hpParse_FromLogin, ///< char-server (login-char)	hpParse_Char,      ///< char-server (client-char)	hpParse_FromChar,  ///< login-server (char-login)	hpParse_Login,     ///< login-server (client-login)	/* */	hpPHP_MAX,};
in this example,

to pass packet from map-server to char-server

1. use hpParse_FromMap in SERVER_TYPE_CHAR

2. check char-server online with chrif->isconnected() function

3. global value can be pass with chrif->fd

 

now this is just in theory ...

 

to pass packet from char-server to login-server

1. use hpParse_FromChar in SERVER_TYPE_LOGIN

2. can hook to loginif->on_ready/loginif->on_disconnect to check if login-server online

3. global value can be pass with .... hmm ... ??

 

I start to think you did something wrong there

in the sample.c, it create a new socket session

sockt->session[fd]
yes in the sample.c, it also can use sd->fd, right ?

but I think sockt->session[fd] is more generic

 

hmm ... need some test ...

Share this post


Link to post
Share on other sites

I start to think you did something wrong therein the sample.c, it create a new socket session
Sample.c have example of putting some values in player session data, while my plugin shows how to pass value and save it in global variable (like, if you want to pass some config of char-server from map-server, which applies to all players, instead of just 1 player)

You can just increase the size of packets and pass as many values or structures as you can...

 

@@AnnieRuru

you have a typo for char_receive_packet
What's the typo?

I just wanted to show before actually receiving to packet, the value is 0, and map-char server loads plugin separately.

 

chrif->fd = map-char

chr->login_fd = char-login

Char-Map : Search map-server Id and then fd, see char_parse_char_select from char.c on how they do it.

Share this post


Link to post
Share on other sites

 

@@Dastgir just a curiosity for what purposes is this btw?

It's just a sample for those who want to learn how to communicate between 2 or more plugins(at different servers , i.e map/char/login) or play with packets...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.