So I coded an IRC client in python using the built in sockets module. I run it from the command line, no pygtk/gui nonsense. Quite straightforward because I am aiming to implement it in to my game in BGE. The only issue I think that may arise, is threading. It runs a loop in the main code-flow to basically check for new messages from the IRC server, strip the messages to only show the actual message being sent, and then print them. But once it successfully logs in, it spawns one thread that is a loop to check for user input, and then it will send a message if the user presses return.
I just don’t know how to really implement this into BGE. This is how far I am / what I am thinking of trying. Any help is heaps appreciated! So tell me if my methodology/thinking is wrong!
My plan, is to have a scene that will act as a “HUD” and can be toggled. This scene will show the chat, players online on IRC, and chat prompt to send messages.
So I have the HUD scene, and I can toggle it with “overlayscene” and “removescene.”
If I have the IRC code run in the HUD scene, when it gets toggled, it is “removed” so it would terminate the code, right?
If that is true, then I thought that I could just have the code run in the main scene and then store the chat buffer into globalDictionary and whenever the HUD scene is toggled it will call that to populate the text UI. But this is assuming that the code will still be running when the main scene is suspended. Is that true?
Another problem arises when the player enters other levels/scenes completely. If I put the code into the main scene, then it would be terminated when switching to another scene, right?
So I guess my main question is: How will I be able to keep my two loops (one is a thread, of course) running when switching to different scenes?
If the IRC script could run in the background somehow, then all I would have to do is send the messages from the server to globalDict and I could access it from any scene.
I was thinking that I could just use a “overlayscene” thingie, and have the script run in that “HUD” scene. The only problem is I don’t know if the IRC code will be terminated when the scene is toggled…Idk, I feel quite lost.
Thanks guys in advance!!