Closed GoogleCodeExporter closed 9 years ago
I just find out that I made a mistake in the writing.
It should be
"It successfully creates an enet host during the test"
instead of
"It successfully creates a test during the test."
Sorry for any inconvenience.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 23 Sep 2012 at 6:18
Hey, thx for this. To be honest I'm also working on basic enet-integration
implementing stuff like gkNetworkManager and such and intergration into the
gamekit message-system... never tested it on a real server but already works in
lan.
Count on the alpha to be integrated within the next 2 month...
Until then everyone have a pretty good start thx to your patch.
Original comment by thomas.t...@googlemail.com
on 23 Sep 2012 at 11:51
The patch will now only to be able to build enet through the Cmake GUI so it is
easy for people to carry along with other gamekit stuff cross platform.
I am still in middle of figuring out how to do thread cross - platform (by
gkThread?) to implement gkNetworkManager. So it can be used on other project
without the crazy CmakeLists change. But it is good to see other people already
start on it.
Thanks.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 23 Sep 2012 at 5:53
So after some works, I think I got a basic Lua interface for network
connections. Hope it will be useful for people. Dertom may have a much better
version already.
The attached TestNetwork.blend is served as simple example for the interface.
However, I got error in compiling in Linux, right now the patch will only works
for Windows.
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
Purpose:
The patch enables developers to access the enet to create network connections
through Lua interface
Disclaimer:
The patch comes with no warranty and no guarantee, developers are on their own
risks for using this patch.
The patch worked for simple tasks, it was not tested against more advance
usages.
The patch was considered as hacks and therefore the codes might be ugly to read.
It currently only been tested on Windows 8 64 bits
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
Additional Note:
Right now, one instance of application can only start one server or one client.
So an instance cannot have both a client or a server, or two servers or two
clients.
Any incoming network messages will be send through Message System, so if the
receiver object does not have a message
listenter, it will not be able to receive any message
enet library uses winsock2.h file. However, since Ogre already includes
windows.h file that comes with older version of
winsock, which will cause redefinition of certian functions.
In order to overcome these problems, one will need to change every windows.h
include in entire Ogrekit to winsock2.h, since
winsock2.h already includes windows.h
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
Instruction:
Use AppOgrekit to execute TestNetwork.blend
Press key S when the scene is loaded to start a server
Start an other instance of AppOgrekit to execute TestNetwork.blend again
Press key C when the scene is loaded to start a client
Then, at the client side, press A, the server side cube should rotate
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
createNetworkInstance
Input: pType 0 indicates server instance
1 indicates client instance
pName The name of the network instance
pAddress The name of the server address if the instance is a client
pPort The port for the network instance to listen to
Return:None
Create network instance based on input
Lua Example:
--To create Server with name "Server" and host on at 127.0.0.1:8080
OgreKit.createNetworkInstance(0, "Server", "127.0.0.1", 8080)
--To create Client with name "Client" and connect to a server at 127.0.0.1:8080
OgreKit.createNetworkInstance(1, "Client", "127.0.0.1", 8080)
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
startNetworkInstance
Input: None
Return: None
Start network instance if one exists
Lua Example
OgreKit.startNetworkInstance()
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
stopNetworkInstance
Input: None
Return: None
stop the network instance if one exists
Lua Example
OgreKit.stopNetworkInstance()
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
deleteNetworkInstance
Input: None
Return: None
Remove the instance and free its resouces if there is one
Lua Example
OgreKit.deleteNetworkInstance()
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
sendMessage
Input: pSender The name of the sender object
pReceiver The name of the receiver object
pSubject The subject of the message
pBody The body of the message
Return: None
Send Message through network to every connection
Lua Example
--Send message across network to an object named "Cube" and the message subject
is "left" with a empty body
OgreKit.sendMessage("","Cube","left","")
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
isNetworkInstanceExists
Input: None
Return: bool To indicate whether there is a network instance
To get bool to indicate whether there is a network instance
Lua Example
--Check if a network instace exists
OgreKit.isNetworkInstanceExists() == false
--------------------------------------------------------------------------------
------------------------------------
--------------------------------------------------------------------------------
------------------------------------
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 7 Apr 2013 at 4:12
Attachments:
Great, I will check the linux-side and will commit asap.
Thx for that.
Original comment by thomas.t...@googlemail.com
on 7 Apr 2013 at 4:21
To Dertom,
Thanks for accepting it and for fixing the Linux part.
Hope it is useful. I am still trying to grasp CMAKE, so there may be some parts
that is not the best way to do it.
Thanks again for everything and hope you have a nice day.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 7 Apr 2013 at 5:04
Hmm,...I'm actually not happy about that winsock2-handling. Doing it like this
will kill us forever if we want to update all affected libraries... looking
into google tells that there seems to be ways to prevent windows.h to include
winsock1. Have a look here:
http://ohmsblog.teamohms.org/2011/05/fixing-winsock-header-file-mess.html
http://stackoverflow.com/questions/5971332/redefinition-errors-in-winsock2-h
Sry, but you will have to revert the winsock-changes again before I can commit
this.
Thx for doing that stuff. I really appreciate it.
Original comment by thomas.t...@googlemail.com
on 7 Apr 2013 at 5:12
Ok, I could compile it on linux. There was no real problem beside a backslash
instead of a slash in an include in gsNetwork.cpp(26) :
==> #include "Network/gkNetworkManager.h"
But actually that was the only problem. The sample works also...
I'm very very satisfied with your code, well integrated and very good
documented (I assume your patch has more documentation than the whole rest of
gamekit :D)
Cudos for this. I will ask erwin to give you write-access to the repository so
you can upload this on your own (after fixing the winsock2-issue as pointed out
in the comment #7).
Thx a lot, Tom
Original comment by thomas.t...@googlemail.com
on 7 Apr 2013 at 6:27
To Dertom,
Thanks for the information on Linux error and WinSock information.
You are right that WinSock solution that I have is very ugly.
I did try methods you mentioned above from Stackoverflow before I replaced all
windows.h with winSock2.h. I also tried the omsblog one, but it still did not
work.
I make CMAKE to define _WINSOCKAPI_ and it does present during compile, but it
does not prevent windows.h to define some of things in WinSock2.h. I remembered
that the first patch does work in Windows 7, but it does not work in Windows 8
anymore. Maybe there is something that I did not realize?
Will look it into further, but do not know when will it be ready since I had no
idea what to do next right now, sorry about that.
Also, thanks about mentioning the write access to SVN. But even if I got
access, I still wish to review with you or other maintainers before I push
anything in the future like in the issue track, is that okay?
Attach is a patch that revert winsock - change, but it breaks Windows build (at
least in Windows 8). Maybe someone will find the missing piece much better and
faster than me. It is not intend for checking into the trunk, but just as a
work that people can investigate on. It also includes fix for the backslash
problem.
Thanks again.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 8 Apr 2013 at 1:22
Attachments:
Sure, you can still e.g. post in the forum or here in the tracker but since you
know "how huge" the active community is, there might be not that much feedback.
Start with simple things.
I will have a look into the enet thingy. I don't have win8, so I can't test
this...but win7 is enough. As long as we don't activate enet as default which
would break out of the box compilation for win8 I am fine for the start if only
win7 works...
Original comment by thomas.t...@googlemail.com
on 8 Apr 2013 at 1:31
Did you try to add the WIN32_LEAN_AND_MEAN-define in the toplevel-cmake?
Have a look here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.as
px
Not sure about win8 though...
Original comment by thomas.t...@googlemail.com
on 8 Apr 2013 at 2:20
To Dertom,
Thanks for the feedback.
The WIN32_LEAN_AND_MEAN was actually one of my first attempts. But it still
does not work.
I included in the top level cmake in trunk like this
if (MSVC)
add_definitions( -D_WINSOCKAPI_ )
add_definitions( -DWIN32_LEAN_AND_MEAN )
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
add_definitions( -D_CRT_SECURE_NO_DEPRECATE )
add_definitions( -DNOMINMAX)
endif()
I know it got in because there are many warnings shows WIN32_LEAN_AND_MEAN
redefinition in compile time. So I turned it off.
I then attempted to add #define WIN32_LEAN_AND_MEAN before every <Windows.h> in
entire trunk, but it does not work either. Maybe I miss one file in the process?
I did do a small sample in Win8 and it seem WIN32_LEAN_AND_MEAN and
_WINSOCKAPI_ should solve the problem. So it must be that I miss something in
CMAKE so these two definitions are not define before all windows.h.
By the way, I think the reason that it gets compile in the first patch that I
send two month ago is because it is not compiled as part of OgrekitCore, but
instead link by AppCppDemo as a lib.
Thanks.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 8 Apr 2013 at 3:30
[deleted comment]
To Thomas,
Thanks for the advice.
A small update
I got network working on Windows without doing a lot of header replacement in
dependencies because of Tomas'advice on unity build.
The key is that in order for enet to build success with OgreKit under windows,
OGRE_UNITY build and OGREKIT_UNITY build must be off. LINUX can still use UNITY
build with enet
I improve the patch so it should be able to compile in LINUX/WINDOWS and even
if enet is off. The Lua API is preserved for networking even enet is not
compiled (it will just not do anything).
However, the way I approach it might hit performance problem?
void sendNetworkInstanceMessage(
const gkString & pSender, const gkString & pReceiver,
const gkString & pSubject, const gkString & pBody)
{
#ifdef OGREKIT_COMPILE_ENET
if(gkNetworkManager::getSingletonPtr()!=NULL)
{
if(gkNetworkManager::getSingletonPtr()->isNetworkInstanceExists())
{
gkNetworkManager::getSingletonPtr()->sendMessage(
pSender, pReceiver,
pSubject, pBody);
} // if
} // if
#endif
} // void sendNetworkInstanceMessag
#ifndef is checked to include/exclude code based on compilation flag. I never
use like this before inside code (I always use only to prevent header
inclusion). I learned it through how gsSound.cpp uses it.
This patch is the intended patch that I will push into the trunk next week if
there is nothing wrong. But I do still want to search way to build with
UNITY_FILE option on and test more.
Hope it helps some people.
Thanks.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 14 Apr 2013 at 12:40
Attachments:
Commit changes in r1266 and r1267.
Thanks.
Sincerely,
Danil
Original comment by KAI.TING...@gmail.com
on 22 Apr 2013 at 6:37
Original issue reported on code.google.com by
KAI.TING...@gmail.com
on 23 Sep 2012 at 6:15Attachments: