View previous topic :: View next topic |
Author |
Message |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Thu Aug 02, 2018 5:00 pm Post subject: Web server plugin |
|
|
So I'm thinking of doing a server plugin that can allow users to connect to the host PC through a browser on any device (i.e. mobile phones) on the same LAN. So users may easily activate/deactivate memory records without alt-tabbing or getting up from the couch to reach their keyboard.
But I can't find a suitable exported function for getting the addresslist. Currently, I have two ideas in mind. Preferably, I will code in C/C++ using the Wt framework and get all necessary information through the Lua engine, caveat being that it requires a lot of reads from the Lua stack.
Alternatively, I can code using Lazarus and get all the tree nodes through the mainform pointer. But the web frameworks available for FreePascal seems lacking.
So, is there any other way I can get the addresslist to the plugin?
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Thu Aug 02, 2018 11:31 pm Post subject: |
|
|
easiest is just use lua and invoke some lua functions like activateMemrec(id) or deactivateMemrec(id)
to call just do:
lua_getglobal(l,"activateMemrec")
lua_pushinteger(id)
lua_pcall(l,1,0,0)
and use luaL_doString ("......") to load your functions
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Thu Aug 02, 2018 11:55 pm Post subject: |
|
|
Thanks, looks like I'll take the C++ option.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Fri Aug 03, 2018 2:26 am Post subject: |
|
|
If you have questions about lua, just ask. it's usually easier than it appears
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Thu Aug 09, 2018 9:08 am Post subject: |
|
|
I'm getting Lua Panic errors by setting a timer to continuously refresh the client page.
---------------------------
Timer Exception
---------------------------
:TApplication->MainForm:TMainForm->pnlExtraMemRecInfo:TCEPanel->:TTimer:External exception E06D7363
Seems there is a conflict with CE's own update timer. Any ideas what might be causing it? My timer does access the addresslist through Lua every second, but I did check that the stack is managed and popped properly after each memory record retrieval. It doesn't crash or freeze immediately when these errors pop up and the addresslist state is synchronized between the browser and CE still. However, once such errors pops up, CE will lock up when closing. So it's not a problem I can ignore.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Thu Aug 09, 2018 9:40 am Post subject: |
|
|
do you use the lua state variable passed by the callback?
you're creating new timers constantly?
do you use threads ?
it could be your c++ code is running destructors on some objects using wrong typecasts or another exception (
https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273 )
and try without other extensions. perhaps they are conflicting (e.g pnlExtraMemRecInfo:TCEPanel is not a native CE object)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Thu Aug 09, 2018 9:53 am Post subject: |
|
|
I set the lua state taken from the exported functions as a global variable. The server instance is started on a separate thread. Timers are only created per web session e.g. refreshing/new user browsing.
I have a feeling it's my extension causing it. Totally forgot I had that extension. Thanks.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Thu Aug 09, 2018 12:16 pm Post subject: |
|
|
on function callbacks from lua always use the parameter it provides. Every thread has a unique lua state and functions can be called from other threads.
if you access lua from a new state, use the getLuaState function to get a new one
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Fri Aug 17, 2018 8:07 am Post subject: |
|
|
So I have been thinking how to implement server push and eliminate the refresh timer on the client side. To do so I would need some way to detect a change in the addresslist. But CE does not support some of the TTreeView events that can easily be used for this e.g. OnAddition.
Thus, I currently have 2 ideas for it:
1. Do a timer on server side instead and periodically check for addresslist changes, either by saving the table and diff-ing the hash or individually check each memrec.
2. Use other events instead such as OnClick, OnMouseExit that are implemented in CE. However, this leaves some gaps where some actions will not be detected and pushed to clients.
Are there any better options I can go for?
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Sat Aug 18, 2018 2:38 am Post subject: |
|
|
right now there's not mich i can think of. OnChange won't work ? (all published properties are available to lua)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Sat Aug 18, 2018 9:25 am Post subject: |
|
|
Yea, OnChange is a TTVChangedEvent, which is hidden in ceguicomponents.pas. I could make use of it, on top on OnAddition, OnDeletion and a few others.
It's fine though, I will just make use of what I have for now and update the plugin again as and when the events become available in future CE versions. Thanks for all the help till now.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Sun Aug 19, 2018 2:14 am Post subject: |
|
|
I tried poking at the TTreeviewWithScroll OnChange event but this was what the Lua engine returned:
Code: | local al = getAddressList()
print(tostring(al.getComponent(0).OnChange))
Error:This type of method:TTVChangedEvent is not yet supported
Script Error |
Thereafter, I searched CE repo for "TTVChangedEvent" which led me to that section in ceguicomponents.pas so I assumed that it was a hidden property. But currently it does not seem possible to assign a function to the OnChange event.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Sun Aug 19, 2018 2:23 am Post subject: |
|
|
ah ok, i didn't check the type. i'll see about exposing more typedefs
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
|