Giter Site home page Giter Site logo

Comments (7)

ROBERT-MCDOWELL avatar ROBERT-MCDOWELL commented on August 12, 2024

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

from as3websocket.

angelhdzmultimedia avatar angelhdzmultimedia commented on August 12, 2024

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.

from as3websocket.

ROBERT-MCDOWELL avatar ROBERT-MCDOWELL commented on August 12, 2024

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.

from as3websocket.

theturtle32 avatar theturtle32 commented on August 12, 2024

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

from as3websocket.

theturtle32 avatar theturtle32 commented on August 12, 2024

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.

from as3websocket.

angelhdzmultimedia avatar angelhdzmultimedia commented on August 12, 2024

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.

from as3websocket.

ROBERT-MCDOWELL avatar ROBERT-MCDOWELL commented on August 12, 2024

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.

from as3websocket.

Related Issues (20)

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.