Coder Social home page Coder Social logo

wikiti / extension-networking Goto Github PK

View Code? Open in Web Editor NEW
32.0 32.0 5.0 2.3 MB

Library developed for OpenFL to facilitate connections between applications, using TCP sockets, and following the scheme of event-driven programming.

License: MIT License

Haxe 100.00%
flash haxe native network networking openfl socket tcp

extension-networking's People

Contributors

wikiti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

extension-networking's Issues

client.send in Android doesn't seem to be working

Hi, after establishing a Server in Windows, opening a Client in Android and connecting to server from the client, trying:

server.send({ x: "something"});

doesn't seem to register on the android client. Maybe I am missing something here though.
I can provide the HaxeDevelop project, with both the server and the client, if needed.
It's a simple in house project so no NDA.

Flash sockets error

The following error is being generated on the client side while targeting flash:

Error #2044: Unhandled IOErrorEvent:. text=Error #2031: Socket Error.
 at networking.wrappers::SocketWrapper()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\wrappers\SocketWrapper.hx:29]
 at networking.sessions.items::ClientObject/initializeSocket()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\sessions\items\ClientObject.hx:89]
 at networking.sessions.client::Client/threadCreate()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\sessions\client\Client.hx:95]
 at networking.wrappers::ThreadWrapper/handler()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\wrappers\ThreadWrapper.hx:64]
 at lime.app::_Event_Dynamic_Void/dispatch()[C:\HaxeToolkit\haxe\lib\lime\3,5,2\lime\system\ThreadPool.hx:25]
 at lime.system::ThreadPool/queue()
 at networking.wrappers::ThreadWrapper()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\wrappers\ThreadWrapper.hx:42]
 at networking.sessions.client::Client()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\sessions\client\Client.hx:59]
 at networking.sessions::Session/start()[C:\HaxeToolkit\haxe\lib\extension-networking\1,3,3\src\networking\sessions\Session.hx:94]
 ...

Things to try:

  • Use latest Haxe, Lime and OpenFL versions. Fixes nothing.
  • Isolate the error in a small project. Fixes nothing.

Required fixes:

  • Refactor library sockets (openfl.net.Socket) to use events instead of synchronous behaviour.
  • Add a XmlPolicyFileServer to handle flash policy files.
  • Create a wiki page about How to allow flash clients. Please, check #4.

Second client that joined the server cannot receive the message

Hello, I'm creating a multiplayer game using HaxeFlixel and this library. Currently, I have a server program that sends a certain message when player joins the game and gives the player a certain ID. The first client gets the message and gets the ID 0, but the second client that joined does not get the message and gets the ID null. I want to get assistance with this issue.

The code in the server that runs when player joins (I know that variable names are bad):

// ...
server.addEventListener(NetworkEvent.MESSAGE_RECEIVED, function(event:NetworkEvent)
{
	switch (event.data.case1)
	{
		case "player_joined":
			var previousPlayers = players.members.slice(0, players.members.length - 1);
			trace("Previous players: " + previousPlayers);
			server.send({case1: "new_player", players1: previousPlayers, playerID: newestID});
			trace("Sended");
			newestID++;
	}
});
// ...

The code in the client that runs when the client receives the message:

// ...
client.addEventListener(NetworkEvent.MESSAGE_RECEIVED, function(event:NetworkEvent)
{
	trace("Client received a message");
	// If case is new player, add a player
	switch (event.data.case1)
	{
		case "new_player":
			trace("Message: new player");
			var playersArr:Array<FlxSprite> = event.data.players1;
			for (i in playersArr)
			{
				i.loadGraphic(AssetPaths.PlayerCharacter__png, true, 32, 32);
				otherPlayers.add(i);
			}
			playerID = event.data.playerID;
			trace("Player ID: " + playerID);
	}
});
// ...

How can I upload the server part on my VPS to run forever ?

Hope you don't mind as I have got many questions ( not issues ).
I know how to compile the haxe files. But I am not sure about how to use it as server on my VPS
How can I upload the server part on my VPS to run it forever?
Would it be feasible to use it for production? For Android?
Is it possible to make the client files kept on a web-hosting to communicate with the VPS having the server file?

Websockets connecting to native server

This is more of a question, rather than an issue.

I can get a client and server both running in neko to connect perfectly, but when I try to run a server in neko and the client in html5 I get the following errors:

Client side

WebSocket connection to 'ws://127.0.0.1:6066/' failed: WebSocket is closed before the connection is established.
NetworkTest.js:4106 NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_INIT_SUCCESS -- {
	message : Connected to 127.0.0.1:6066
}
NetworkTest.js:4106 NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_CONNECTED -- {
	message : Connected to 127.0.0.1:6066
}
NetworkTest.js:4106 NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_MESSAGE_SENT -- {
	obj : 80F87D76-3DF5-C123-2AF8-929FDAACC195 ([object Socket]), 
	message : {
		metadata : {
			client : {
				active : true, 
				uuid : 80F87D76-3DF5-C123-2AF8-929FDAACC195
			}, 
			server : null
		}, 
		data : {
			verb : _core.sync.update_client_data, 
			uuid : 80F87D76-3DF5-C123-2AF8-929FDAACC195
		}
	}
}
NetworkTest.js:4106 NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_DISCONNECTED -- {
	message : Connection lost: End of file was encountered
}
3NetworkTest.js:4106 NetworkLogger.hx:60: # NETWORK ERROR -- $ -- Socket is not initialized.

Server side

NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_CONNECTED -- { server => { info => 63209B61-7032-9506-6198-475B2621274F (local), max_connections => 24, port => 6066, _session => [object Session], clients => [], _thread => { _on_start => null, _active => true, _mutex => { _mutex => { m => #abstract } }, _on_loop => #function:0, _on_stop => null }, ip => 0.0.0.0, _uuid => null, _mutex => { _mutex => { m => #abstract } } }, client => 8E0F0672-84FA-ECBC-574B-BA9F61C9B3D9 (127.0.0.1:52070) }
Main.hx:39: Connected
NetworkLogger.hx:60: # NETWORK ERROR -- $ -- Socket is not initialized.
NetworkLogger.hx:60: # NETWORK EVENT -- $ -- NETWORK_EVENT_DISCONNECTED -- { server => { info => 63209B61-7032-9506-6198-475B2621274F (local), max_connections => 24, port => 6066, _session => [object Session], clients => [], _thread => { _on_start => null, _active => true, _mutex => { _mutex => { m => #abstract } }, _on_loop => #function:0, _on_stop => null }, ip => 0.0.0.0, _uuid => null, _mutex => { _mutex => { m => #abstract } } }, client => 8E0F0672-84FA-ECBC-574B-BA9F61C9B3D9 (127.0.0.1:52070) }

Are connections from web sockets -> native sockets not supported?

Wrong disconnection events order for clients

When a client closes his session, the following events are being fired:

- NETWORK_EVENT_CLOSED
- NETWORK_EVENT_DISCONNECTED

They should be fired in the following order:

- NETWORK_EVENT_DISCONNECTED
- NETWORK_EVENT_CLOSED

Uncaught exception - Invalid call from networking.sessions.Session::disconnectClient line 124

I get the following exception when calling the disconnectClient() method on a Server-Session.

Called from networking.sessions.Session::disconnectClient line 127
Uncaught exception - Invalid call

To repoduce, you can instanciate the attayched class and try to connect two clients.
After connecting the second client, the first one should be disconnected but instead the Application crashes.

CommandServer.zip

How ever I was able to fix this issue by Modifieing the disconnectClient() method in Session.hx to this:
(Castes the network_item from Dynamic to Server Class )


public function disconnectClient(cl: ClientObject = null) {
  switch(mode) {
    case SERVER:
      if (network_item == null || cl == null) return;
      var server:Server = network_item;
      server.disconnectClient(cl);

    case CLIENT:
      if (network_item == null) return;
      stop();
  }
}

Would love html5 support

currently building a creation, idea, problem database app in openfl, however a simple html5 version would be very helpful for marketing and in order to reach a wider audience.

Demo 'basic-example' crashes on neko when starting server

I am attempting to compile under Neko (lime run neko). When pressing the 'Server' button in the 'basic-example' demo, the application crashes with this error message:

Called from ? line 1
Called from ApplicationMain.hx line 79
Called from ApplicationMain.hx line 111
Called from lime/app/Application.hx line 267
Called from lime/_backend/native/NativeApplication.hx line 158
Called from a C function
Called from lime/_backend/native/NativeApplication.hx line 440
Called from lime/_macros/EventMacro.hx line 101
Called from openfl/display/Stage.hx line 221
Called from openfl/display/Stage.hx line 1048
Called from openfl/display/Stage.hx line 1201
Called from openfl/display/Stage.hx line 984
Called from openfl/display/Stage.hx line 1070
Called from openfl/display/DisplayObject.hx line 350
Called from a C function
Called from openfl/events/EventDispatcher.hx line 218
Called from networking/sessions/Session.hx line 226
Called from networking/utils/NetworkEventsQueue.hx line 47
Called from openfl/events/EventDispatcher.hx line 97
Called from openfl/events/EventDispatcher.hx line 218
Called from networking/sessions/Session.hx line 221
Called from /usr/local/lib/haxe/std/neko/_std/Std.hx line 34
Called from a C function
Called from <header> line 1
Called from networking/wrappers/SocketWrapper.hx line 210
Called from /usr/local/lib/haxe/std/neko/_std/sys/net/Socket.hx line 191
Uncaught exception - std@socket_peer

I am running on Mac OSX, using Haxe 3.4.

"Critical Error: Allocating from a GC-free thread" when using VSCode debugger

I am not certain that the issue I am experiencing is directly related to this library. However, after producing this minimal example, I believe that some connection may exist.

Versions:

  • Haxe: 4.0.0-preview.4+1e3e5e016
  • Lime: 7.0.0
  • OpenFL: 8.4.1
  • extension-networking: 1.4.2
  • hxcpp: 4.0.4
  • hxcpp-debug-server (i.e. hxcpp debugger): 1.0.0
  • Visual Studio Code: 1.26.1

Steps to reproduce:

  1. Open the folder examples/basic-example in Visual Studio Code.

  2. Set Build Target to Windows, Build Configuration to Debug.

  3. Ctrl-Shift-B to build (lime build windows -debug --connect 6000)

  4. In the Debug sidebar, select a Windows/HXCPP configuration.

    I used the following:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Hxcpp",
            "type": "hxcpp",
            "request": "launch",
            "program": "${workspaceRoot}/bin/windows/bin/basic-example.exe"
        }
    ]
}
  1. Start debugging.

The program begins fine, but as soon as I click "Server," I get the message Critical Error: Allocating from a GC-free thread and the program terminates.

If I try to simply run the same program (no recompilation) without debugging (lime run windows -debug --connect 6000), everything seems to work as expected.

Ios Support

Hey sorry to ask again for support but I'm just curious if ios does works as a client. I'm testing my project in an ios simulator and looking at the network support it shows that it does indeed have a connection to the server and how it is sending packets however the server is not receiving them in the slightest. Also the server is getting connected and disconnected calls from the simulation. Any help would be very much apperciated ๐Ÿ˜„

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.