Hi, I have been asked to help a card playing club to develop some way of allowing its members to play their rather obscure game of choice online. I have written software for standalone Macs and PCs using Xojo and done some website building in the past, mainly using uncomplicated HTML.
I had hoped I could build something for the club’s own website so that its members would not incur any charges for playing online. I don’t really want to learn JSON and use a third party website, however, I don’t want to reinvent the wheel and start right from scratch.
If anybody here can advise me on the best way to proceed, I’d be very grateful. Thanks, Steve
There’s a decent overview on creating JSON-RPC servers here.
Here’s a very simple example of a JSON-RPC request and response, just looking at these should be enough for you to get the concept ( the id member is whatever you choose, it exists to enable you to match responses to requests ):
Thank you for that information, Steve. My original hope was that I might be able to do the whole thing in Xojo but that looks unlikely now. At some stage, I think I may need help from a freelance who understands how a server could be set up, preferably a VPS, and how the layout of the room or table for the players and the various interactive functions could be rendered as JSON. I’ll have to read up as much as I can over the weekend. There’s a lot of stuff out there about how to write JSON objects, arrays etc but that’s not helping me see a way through to a working solution.
Well thanks for the encouragement, Wayne, but I’m not sure if it’s do-able by me on my own. First of all, I’ve only ever done standalone apps, not Web apps in Xojo, although I am playing about with the Web apps introduction in the documentation now.
I would have to start right from square one. In all the online card rooms I have seen over the past few days there appears to be a coding structure in place using JSON allowing players to drop a card in a rectangular card space and have it slide along to the left until it stops a few millimetres from the extreme LHS or from another card, if it encounters one first.
Cards can be flipped over and dragged around the screen singly or in groups, slid over each other and over other players’ cards etc. But more than this, I’m concerned about the mechanics of how it works with several players sitting at the same virtual “table”. They have to have a private card space where no-one else can see their cards and in some cases, if they have bad eyesight, they can hover over a card in their “hand” and have it enlarge considerably outside their private card space in the full window, but only they have to be able to see the enlarged version, not the other players. These are all problem I have never encountered or thought about before.
Thank you, Jay. I haven’t seen that site and have to go out shortly, but will take a look at it tomorrow. Signing off for tonight in the UK.Thanks
Maybe you could clarify the concept for me. If I were building a desktop card game, I would just create a main window in which the game happens, the user clicks on buttons, selects cards, flips them face up or down, puts them in groups, drags them around etc. I can work out how to do that.
What is the Web equivalent of the main window, given that several people with different browsers will need to log in to a website and play the game in different browser windows?
The difference is that they won’t all see exactly the same thing in their windows. They will each have a private hand of cards no-one else can see, they may be able to click on some buttons only when it is their go. There may be buttons only they can see and click on (buttons which might sort their own cards in different ways, for example). There may be a table host who may be the only one entitled to click on the Deal button and the Reset and shuffle button, but in general, most of the flipping and moving around of cards and placing of them in the discards pile and various display areas on the browser windows will be visible to them all. I just can’t get my head around what it is I have to build exactly. Thanks if you can help here.
What you’re needing is called a WebPage. Each person that logs into your app gets their own Session instance as well as any WebPage and its contents, automatically generated at runtime. They are functionally separate from one another and don’t share data between them unless you specifically do that (or put some data somewhere global, like a module).
One thing that you’ll need to get used to is that calls sent to/from the browser are always asynchronous and sometimes not instantaneous like they are on desktop.
My suggestion is that you build up to your concept gradually and Learn how Xojo behaves. Play around with some of the example projects and connect to it from several different browsers/machines. Don’t use multiple tabs in the same browser as a gauge though as they’ll conflict with one another.
Thanks Greg. I’m not at my computer at the moment. So if I have three people logged in to a game I need three identical Web pages on the server with the game furniture and functions including one to drag a card from A to B, say. When one player carries out that action on his browser screen, the function needs activating on all three web pages at the server so that all the players see the same thing?
OK thanks, I’ll have to check out how that works but it looks as though I need a server (Xojo Cloud?) first along with a web licence so that I can actually put the app out there and access it from different machines.
Well that’s as maybe, Steve, but you’re not suggesting what I should use instead so I am beginning with what I know and hoping to build on that.
Anyway, I seem to have made a start. My default browser is Chrome. When I create and run a web page the local IP address and port are given as 127.0.0.1:8080 so I have put a default button and two ordinary buttons on that main page and created a new web page called gamePage with various web controls on it.
This one doesn’t work. Xojo says there is an end quote missing and that there is a syntax error. I’ve tried it without http://www but it makes no difference.
Anyway, it looks as though I don’t need to buy a web licence just yet. I have found, using Safari (it doesn’t work in Chrome), that I can open a private browser and then a second private browser in a tab and enter one of the .io games I mentioned earlier as two different users to see what is going on and this also works with my effort above, after deleting the third, inoperative button on the main page.
My next step is to work out how to provide users with usernames and passwords and how to limit access to a gamePage to usernames who are expected. Then my main headache will be to provide graphic viewing areas that are private to the various users, so that no-one sees anyone else’s cards. Thank you all for input so far.