Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG?] Client not telling server to close, server not detecting "close" event. #34

Closed
angelhdzmultimedia opened this issue Mar 8, 2021 · 7 comments

Comments

@angelhdzmultimedia
Copy link

Can you please guys give me a hand here?

ryo-ma/deno-websocket#16

My Deno WebSocketServer dispatches the "close" event with the Javascript built-in WebSocket when I close the HTML page.
But not with the AS3WebSocket lib when I close the NativeWindow. I even tried listening to the NativeProcessErrorEvent.ERROR event and force the websocket to close manually. The other events dispatch ok (new message and new client connection).

Thanks, cheers.

@ROBERT-MCDOWELL
Copy link

is there any NativeWindow events that can help you like "closing"?
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:closing

@angelhdzmultimedia
Copy link
Author

angelhdzmultimedia commented Mar 8, 2021

is there any NativeWindow events that can help you like "closing"?
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:closing

Thanks for the fast response.

Yeah, I guess I can listen to the Event.CLOSE event on the NativeWindow and call websocket.close(). But now I'm thinking... if in HTML/Javascript I don't have to listen to any UI event to make the client websocket let the server know it's being closed, why would I have to make it in an AIR application? The websocket should automatically close when the window is closed and the WebSocketServer would immediately know that the client was closed and the "close" event would be being dispatched.

This is my JavaScript WebSocket client code:

const ws = new WebSocket("ws://localhost:3555");

// Register event listeners for the open, close, and message events
ws.onopen = () => {
  console.log("WebSocket ready!");
  ws.send("Hello World!");
};

ws.onmessage = (message) => {
  console.log("Received data:", message.data);
};

ws.onclose = () => console.log("WebSocket closed!");
ws.onerror = (err) => console.log("WebSocket error:", err.error);

See? I'm not handling any UI event on the HTML window when it "closes", and the Javascript WebSocket class still let the server know that the client is not connected anymore.

So I think this may be a bug in the AS3WebSocket library. I never had issues with these events in any other language like Dart or Python. All the events are dispatched correctly. Also, using the Socket class in AS3 and using a non WebSocket server in NodeJS for example, all events dispatch correctly too.

@ROBERT-MCDOWELL
Copy link

First of all, how do you use the AS3 websocket if it's not in an AIR app?
the NativeWindow has a "CLOSING" event, "CLOSE" is another event. "CLOSING" is fired just before the window closed.

@theturtle32
Copy link
Owner

Whoa.... people are still using this? I'm genuinely surprised, given that Flash is pretty much dead!

@theturtle32
Copy link
Owner

theturtle32 commented Mar 8, 2021

I developed this library for a browser-based web app, and haven't ever tested it in an Air context on Android, so I'm not really familiar with these NativeWindow events you're talking about, but watching for them and then manually closing any open connections sounds likely to be the right approach with least effort. You could fork and update the library if you want to hook into those things under the hood. I'll accept a PR if you do, but I am generally considering this library to be obsolete and unsupported at this point.

@angelhdzmultimedia
Copy link
Author

First of all, how do you use the AS3 websocket if it's not in an AIR app?
the NativeWindow has a "CLOSING" event, "CLOSE" is another event. "CLOSING" is fired just before the window closed.

I get your irony. I'm aware Flash Player died, so no more Flash Player on the web. I was just being specific about my environment to have a better clue at what's happening.

I know it's Event.CLOSING, it was just a typo for all the times I've wrote the word "close".

I was just having a nostalgia moment, trying Deno for the first time, and decided to use an AIR app as the client to test it.
But I'm not using any of this in production of course.

Although, there are still many AS3/AIR developers out there using the AIR SDK that Harman owned from Adobe.
Others like me moved on to other technologies (ReactNative/TypeScript, Xamarin/C#, Fluttert/Dart). And a very few others moved to Haxe and OpenFL.

But I didn't intend to turn this thread in a debate about AS3/AIR/Flash obsoleteness. Just wanted to know why this AS3WebSocket lib isn't telling the server that it disconnected when closing the NativeWindow.

Cheers. Stay safe.

@ROBERT-MCDOWELL
Copy link

nothing is dead on computer, it's just an illusion for the sheep following the matrix...
Java is not dead, and people said 10 years ago it's dead for the web, Flash is the same
and the next couple of months/years it will rebirth as a phoenix with WASM. (check ruffle-fs)
with wasm, I'm pretty sure javascript will also die... and the sheep will jump from the cliff, believing they understood everything from their masters matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants