apache / royale-asjs

Apache Royale ASJS
Apache License 2.0
369 stars 116 forks source link

Does Royale have a Socket method in the future? #416

Open JamesPengTW opened 5 years ago

JamesPengTW commented 5 years ago

Royale currently seems to use the HTTPService method in the transmission part of the network data. There is no Socket transmission method. Does Royale have a Socket method in the future?

carlosrovira commented 5 years ago

Hi James, we want to support all communication for sure. About Socket, do you mean WebSockets? or Sockets in general?

Currently we support AMF protocol and maybe I could be wrong but I think there's some BlazeDS implementations out there for sockets with Java, but I never used it.

JamesPengTW commented 5 years ago

Is Sockets in general. Flex provides a Socket method for the delivery of messages.

by example in Flex: import flash.net.Socket; import flash.events.Event; import flash.events.ProgressEvent;

private var DataSocket:Socket = new Socket();

public function connect():void { DataSocket.connect(ServerIP,ServerPort);
DataSocket.addEventListener(Event.CONNECT,NetworkDeployConnect);
DataSocket.addEventListener(ProgressEvent.SOCKET_DATA,ServicePackageSocket); }

private function NetworkDeployConnect(event:Event):void { var message:ByteArray = new ByteArray(); message.writeUTFBytes(Socket_Instruct+"\r\n"); DataSocket.writeBytes(message); DataSocket.flush(); }

private function ServicePackageSocket(event:Event):void { while(DataSocket.bytesAvailable) {

}

}

There seems to be no such feature in the current version. Will this method be added in the future? This will enable an interface for the ServerSocket architecture on the server side.

aharui commented 5 years ago

There is no Sockets class in Royale yet, because nobody asked for them until you did.

I'm not an expert on Sockets, but I'm not sure there is a way to emulate Flash Sockets in the browser. Input from others is welcome, but if you decide not to use Royale, how would you implements sockets in your non-Royale app? Whatever that is, it could be turned into a Royale class, but it may not match Flash sockets exactly.

JamesPengTW commented 5 years ago

That's just what I used to present how Flex used Sockets. I know that the current Royale does not support Socket. In fact, I was surprised that there was no support for Socket in Royale. Because the network streaming provided by Socket is actually more flexible and programmable.

In my project, my server-side uses Java. It provides front-end web pages and mobile device applications. I use Socket as a stream of data. It is so reliable and efficient. Especially in the instant batch transmission of large data.

I sincerely hope that Royale will be able to add Socket methods in the future. I will continue to use Royale as the programming language for my project. In fact, I am using it for my current project. I also publish the related Royale project for my test on my own Chinese blog.

Finally, thanks to the Apache Royale engineer. Thank you for your contribution and the hard work of this project. ^^

aharui commented 5 years ago

If you did not use Royale how would you access Sockets from the browser? Would you use WebSockets? I'm not sure Browsers allow direct access to TCP sockets.

Royale is an Apache project which means that anyone can contribute code to it. You are more than welcome to contribute a Socket implementation for Royale.

ROBERT-MCDOWELL commented 5 years ago

socket IO and webrtc can be used on js side. I know that the last js api can even have udp sockets (ecmascript 9)