Jump to content
code34

OO BME2 - oriented object Bus Message Exchanges

Recommended Posts

Bus message exchange
Lastest version: 2.4 by Code34

 

 

Description
OO BME is a class (object oriented) that permits to build a main BUS messages between clients & server and transfert data between clients & server.

28mk75l.jpg


Like to Donate ? Donate with paypal

 

Github: https://github.com/code34/oo_bme2.vr
Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling

Features:

- build one main bus message

- Works in local & MP

- rewrite of BME 1.0 in OO way

- Asynchronous remote execution

- Synchronous remote execution (like promise in js)

 

Licence:
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author

Documentation:

	/*
	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2016-2018 Nicolas BOITEUX

	CLASS OO_BME
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 
	*/

	/*
	Function: 
	_bme = "new" call OO_BME;
	Create a new bme object (require to create at same time a handler)
	*/

	/*
	Function : _result = ["remoteCall", ["remotefunction", parameters, targetid, defaultreturn, timeout]] call _bme;
	@remotefunction is a string declare in clienthandler or serverhandler file
	@parameters of remotefunction
	@targetid clientid of the target or 2 for server
	@defaultreturn : default return, in case of no return of the target
	@timeout: limit of time to wait for the answer of target
	*/

	/*
	Function : ["remoteSpawn", ["remotefunction", data, "target", playerid]] call _bme;
	@remotefunction is a string declare in clienthandler or serverhandler file
	@data paramters of remotefunction
	@target is a string ("client" or "server" or "all") declare the target where the remote function will be exectued
	@playerid (optionnal) is a scalar defined by the player id where the code should be executed
	*/

	How to declare remote functions
	===========================
	You have to declare your remote functions as normal function with global declaration name

	The handler declaration must respect this syntax:

	remotefunction = { code to execute on other side }
	
	You can declare thoses functions directly in your code. 

Readme:

 

	/*
	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2013-2018 Nicolas BOITEUX

	Bus Message Exchange2 (BME)
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 
	*/

	Create a main bus message between clients & server
	
	Usage:
		put this code into your mission init.sqf
		call compile preprocessFileLineNumbers "oo_bme.sqf";

	See example mission in directory
	
	Licence: 
	You can share, modify, distribute this script but don't remove the licence and the name of the original author

	logs:
		2.4 - fix remotecall, add timeout, switch to vr map, clean examples, add new oop, fix handlers with schedule code
		2.3 - fix queueing, log, add new oop 
		2.2 - delete useless old handlers
		2.1 - add remoteCall
		2.0 - first implementation


Examples

	/*
	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2016-2018 Nicolas BOITEUX

	CLASS OO_BME
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 
	*/		

	#include "oop.h"
	
	call compile preprocessFileLineNumbers "oo_bme.sqf";
	call compile preprocessFileLineNumbers "example.sqf";

	sleep 2;

	bmeclient = NEW(OO_BME, nil);

	// First Example - remoteCall - synchronous call
	if(local player) then {
		private _count = 0;
		while {_count < 10} do {
			_result= ["remoteCall", ["getServerName",  (name player), 2, "nothing"]] call bmeclient;
			hint format ["RemoteCall from client: %1", _result];
			_count = _count + 1;
			sleep 1;
		};
	};

	// Second Example - remoteSpawn - asynchronous call
	if(local player) then {
		private _count = 0;
		while {_count < 10} do {
			_message = "hello server, remoteSpawn message send from client";
			["remoteSpawn", ["sendServerMessage", _message, "server"]] call bmeclient;
			_count = _count + 1;
			sleep 1;
		};
	};

	// Third Example - remotespawn - asynchronous call from server to client
	if(isserver) then {
		private _count = 0;
		while {_count < 10} do {
			_message = "hello client, message send from server";
			["remoteSpawn", ["sendClientMessage", _message, "client"]] call bmeclient;
			_count = _count + 1;
			sleep 1;
		};
	};
  • Like 2

Share this post


Link to post
Share on other sites

Hi Kremator :)

 

As this time, not really, cause there were a really big positive update on ARMA3 native netcode since 2 years.

Share this post


Link to post
Share on other sites

:dozingoff:  Any example for applications? Because it seems a lot of work just for remoteExec a hint.

 

Share this post


Link to post
Share on other sites

Lol yes i know :) BME is a very old netcode that was build before remotexec & BIS_fnc_mp, at the time where netcode of ARMA was very bad and i need something to stabilize it.

 

For common usage, it s depricated, i still use it in some code, and publish it for who want to check.

  • Like 1

Share this post


Link to post
Share on other sites

Hi guys,

 

Just release the version 2.1 of BME

 

This last release adds the support of synchronous call of remote function :)

 

example:

client side:
_result= ["remoteCall", ["getServerName",  name player, "server"]] call global_bme;

will return directly the output of the server side function execution

server side:
BME_netcode_server_getServerName = {
	if(isNil "counterserver") then { counterserver = 0;};
	counterserver = counterserver + 1;
	format ["hello %1, my name is server%2 and i return you a result", _this, counterserver];
};	

Have fun :don15:

Share this post


Link to post
Share on other sites

For more informations, on how it works, you dont need anymore to declare handler :)

 

you juste have to call your target function with BME :D

Share this post


Link to post
Share on other sites

just publish the hotfix for remotespawn and client that dont receive informations.

Share this post


Link to post
Share on other sites

hi,

 

im looking for any testers for this last release :)

Share this post


Link to post
Share on other sites
Guest

The Armaholic mirror has been updated with the new version:

 

news_download_a3_3.png
OO BME2 v2.1.1

 

 

** the version 2.1.1 is 'invented' by me to indicate the hotfix version

Share this post


Link to post
Share on other sites
7 hours ago, foxhound said:

The Armaholic mirror has been updated with the new version:

 

news_download_a3_3.png
OO BME2 v2.1.1

 

 

** the version 2.1.1 is 'invented' by me to indicate the hotfix version

 

LOL :) no problem with that ! nice workaround ;)

Share this post


Link to post
Share on other sites

hi Dudes,

 

Just release the 2.2 version:

  • delete useless old handlers
  • replace by an example file

 

You don't have anymore to declare your remote functions with extra prefix. A global declaration of the function anywhere in your code, is enough to make it works.


 

exemple:

remotefunction = { your remote code };

 

Share this post


Link to post
Share on other sites

Hi Dudes,

 

Just release the 2.3 version

  • fix queueing,
  • fix logs
  • add new oop version

i also create new git branch "develop" where will be done all next developement before release. If you have any requests dont hesitate to contact me.

Share this post


Link to post
Share on other sites

Hi Dudes :)

 

I just release the version 2.4:

  • fix remotecall,
  • add timeout,
  • switch to vr map,
  • clean examples,
  • add new oop,
  • fix handlers with schedule code

Remotecall should be now totaly efficient and more interesting than arma remote function exec :)

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×