[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Using the socket library
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Using the socket library

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2 3  4  

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Tue 30 Nov 2004 07:08 PM (UTC)
Message
Quote:

That is an interesting solution, but kind of pointless.


Well, in conjunction with another project I'm about to announce, I was trying to be helpful. I gather what you are trying to do is capture the "songchange" event from Winamp?

I've done a bit of a search of the web and haven't seen many examples of how people might be doing that in practice.

How does this work exactly? Does Winamp actually post a message into your app's Windows event queue (eg. MUSHclient in this case)? eg. the WM_SONG_CHANGE_EVENT? Or does it call some code somwhere?

What I thought might be useful is that if Winamp can be configured to do "something" at song change time, then that something might be to run a small program that sends the UDP message to MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #16 on Tue 30 Nov 2004 09:29 PM (UTC)
Message
You can use a Winamp plugin, but the default COM plugin doesn't have events. You could set a timer to refresh every second, but since you'll only be satisfied with an event, that's unacceptable :P

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #17 on Wed 01 Dec 2004 04:55 PM (UTC)
Message
I don't use teh default plugin. Someone else made one that has the one event for song changes. This is the one case I have used such an interface, and the inability of it to work right stopped me from designing other things myself that would have used it.

As for how the WinAmp plugin works Nick, it is like any other ActiveX component. Yes, it does pass the events along to the application that created the instance. The problem is that Mushclient 'is not' the application that created it, the script engine was. So it is the script engine that is recieving the events fired by the plugin. Lua is designed to deal with this by instancing a connection point/event handler, which seems to do:

1. Read the objects internal interface layout.
2. Assigns each event found to a function.
3. Creates dummy versions of each function.

Then you overwrite the dummy function with the real one in your script. Since the script remains in the engine at all time, in theory, Lua, and others that support it, should automatically start up and respond to such events when they arrive, since its own event manager is supposed to do that. At least it 'should', though I haven't tried testing it.

Not sure it is would be WM_SONG_CHANGE_EVENT though. The source code for it doesn't show, it just appears to pass the even it recieves itself from Winamp on to the application that instanced it. The source code is at http://mysite.wanadoo-members.co.uk/johnadcock if you are curious and the relevant file is WinampCOMCP.h, where the connection point code is set up for passing on the message. The plugin doesn't need to know what the actually message is and most compilers (and apparently whatever is buried in Lua) don't require the user to know that, just what the general name of the event is. I have no idea how or why it works that way.

However... There may be something in the interfaces for scripts that lets the application using them intercept the messages from such events. But then you would need to read the idispatch interface info and set things up to work. Basically, events in scripts are handled much like the OnPluginLineRecieved and other functions. They are called only if they exist, otherwise they get skipped (or apparently with Lua, they just call an empty function with the right name).
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #18 on Fri 03 Dec 2004 03:35 PM (UTC)
Message
Which plugin is this? I'd like to download it.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #19 on Fri 03 Dec 2004 04:27 PM (UTC)
Message
http://mysite.wanadoo-members.co.uk/johnadcock

Like I said in the last post Poromenos. ;) I did notice a few bugs in it. One or two of the commands didn't seem to work when tried. However, I am sure I posted something on it before that listed the available functions and properties. Ah, here we are:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2823

Its the .ToggleRepeat and .ToggleShuffle functions that don't seem to work. Everything else listed works, including the SongChange event, if we could just figure out how to properly respond to it...
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #20 on Fri 03 Dec 2004 04:53 PM (UTC)
Message
Bleh, I should read posts more carefully :P I'll take a look at it :)

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #21 on Fri 03 Dec 2004 05:02 PM (UTC)
Message
ToggleRepeatPlay and ToggleShufflePlay work fine for me...

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #22 on Fri 03 Dec 2004 09:38 PM (UTC)
Message
Hmm. I must have misread something myself. I left of the 'Play' at the end of those. :p
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #23 on Sat 04 Dec 2004 12:56 AM (UTC)
Message
I don't think it would be hard to make the plugin send a UDP packet to MC on the event. I don't know if that's what you want, though.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #24 on Sat 04 Dec 2004 04:18 PM (UTC)
Message
Hard no. But imagine if it was something that generates events, but you don't have the code to change it. Nearly every ActiveX program or control does have events that drive it. In the case of WinAmp, it may be possible to modify the plugin to use UDP, but that is a 'very rare' case. Like I said, the only reason I have not even tried to integrate some other things in to Mushclient through script is precisely because in virtually any and all other cases, you would have to build and entire shell around the control or application, just to gain access to the one feature you can't already use through scripting. That is just rediculous and so far beyond what the average script writer could hope to manage that it may as well be impossible. And yes, an 'average' script writer may be willing and able to use ActiveX, just not if they have to create a special wrapper for it to use it right.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #25 on Sat 04 Dec 2004 11:39 PM (UTC)
Message
Ah, you meant generally. Hmm, can't MC act as the wrapper? Maybe there could be a OnCOMEvent function or something.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #26 on Sun 05 Dec 2004 05:15 AM (UTC)
Message
I know I've asked this before, but I just don't see how an external COM object can just kick into life a script whose engine doesn't happen to be running at the time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #27 on Sun 05 Dec 2004 01:09 PM (UTC)
Message
Well, MC would ignore the event if the engine wasn't running. (Assuming acting as a wrapper is possible, I haven't worked much with COM so I don't know).

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #28 on Sun 05 Dec 2004 09:44 PM (UTC)

Amended on Sun 05 Dec 2004 09:45 PM (UTC) by Shadowfyr

Message
Well Nick.. I am not clear what you even mean by that. For the script to remember its own internal variable states it must remain loaded in the engine, even if the engine itself it technically idle. However, I would have to guess that, for event managers to work at all, the engine itself must have code that continues to run, even when the script itself is suspended. Amoung that code would be an event handler, which would capture events from connected objects. If the event handler recognizes an event that is not part of the engine itself, it would check it against objects that it has connection point for and wake-up the script long enough to execute the appropriate code, then suspend it again when done. If something like this was not in fact possible, then there would be absolutely no point in even providing the ability to create such a connection point for an ActiveX object. Events are designed to push program execution, even if there is no 'loop' in the application/script that is in continual operation, aside from a basic one that just makes sure the program doesn't exit until all objects are released.

Guess I will have to actually download the latest version and try some stuff. Been busy with other things, so hadn't gotten around to actually experimenting yet. However, your assumptions that some things can't or won't work flys in the face of the whole intent behind having such features in a script language in the first place.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #29 on Sun 05 Dec 2004 10:44 PM (UTC)
Message
Shadowfyr, if Nick says it can't work in MC, chances are that he's right. :-) He did after all design it and he does know what his event handling looks like.
Quote:
Events are designed to push program execution, even if there is no 'loop' in the application/script that is in continual operation, aside from a basic one that just makes sure the program doesn't exit until all objects are released.
Wrong. You need a 'basic loop' that is in continual operation checking for messages.

Besides, there's an awfully big difference between something being possible and something not taking hours and hours of work to do to satisfy an extraordinarily small audience (as far as I can tell, you.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


39,406 views.

This is page 2, subject is 4 pages long:  [Previous page]  1  2 3  4  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]