Web Server example

Is the page being displayed with a blue header bar at the top with a icon in the left and right hand side, or do you just get a plain un-formatted page ??

What browser are you using ?

I can’t figure out how to add the ServerSocket, I have added a ServerSocket to the app and in it’s add socket event I added this:

  Dim QnD As New QnDHTTPd(rootFolder)
   Return QnD

But won’t that class need to be called from somewhere ?

http://documentation.xojo.com/index.php/ServerSocket

[quote=17294:@Peter Cruickshank]Is the page being displayed with a blue header bar at the top with a icon in the left and right hand side, or do you just get a plain un-formatted page ??
[/quote]
Unformatted, for both links. Interestingly it appears that Firefox (which I’m using) doesn’t request the JS files at all, just the CSS file.

[quote]
I can’t figure out how to add the ServerSocket, I have added a ServerSocket to the app and in it’s add socket event I added this:

  Dim QnD As New QnDHTTPd(DocumentRootFolderItem)
   Return QnD

But that fails as the DocumentRootFolderItem is unknown, should this be Page ??

Also, won’t that class need to be called from somewhere ?[/quote]

Yes, sorry: by DocumentRootFolderItem I meant “insert the actual folderitem that represents the document root/page in your code.”

Make the ServerSocket a property of a Window (or of the App, or a Module, etc. Someplace that won’t go out of scope) and use it’s Listen and StopListening methods to turn it on and off.

AddSocket is where you prep a new connection/socket for use by the ServerSocket:

Event Function AddSocket() As TCPSocket Dim page As FolderItem = SpecialFolder.Desktop ' any folder or file; using the Desktop for example only Dim sock As New QnDHTTPd(page) sock.AllowDirectoryIndexPages = False sock.Authenticate = False sock.KeepListening = False 'since we're using ServerSocket Return sock 'return the prepared QnD socket to the ServerSocket End Function

This is how the page should look after clicking the icon at the top left.

Page

Andrew, As you can tell I am not an experienced Xojo / RB Programmer.

This is only a very small part of the data collection solution I am working on which combines electronics, micro-controllers, bluetooth, multiple serial ports, a database, html, javascript, ajax and finally a simple web server to display the database config and data.

I’ve now spent a week on something which I thought would take an hour, and this is obviously beyond my limited xojo capabilities and I just can’t spend any more time trying to get this part to work, I will have to find another solution.

Thanks very much for your patience and help, I am giving up on this now.

Cheers

PeterC

Have you thought about using a web app to serve the data?

Wayne, Thanks, yes that’s an option, nodejs is another option of which I have quite a lot of experience.

But I was really trying to do it all with Xojo and have minimum install issues / dependencies.

I was thinking of a Xojo web app actually. It has it’s own built in web server, can be run as a service/daemon and can launch console apps in that service space that can handle the dirty work of data collection.

But can it serve pages from a folder or only pages that are created internally ?

Have a look at this . It’s old, but still works.

Hi Andrew;

Andrew, many thanks for all your help, I did not mean to imply that I had spent a week working on your http server, just that I had spent a week trying to get my pages to display reliably using xojo.

I’m not giving up with your solution, but with Xojo. I have already written all of the other data collection part in xojo, but may now port it all to nodeJS and drop xojo completely for this project, that is going to be a big job, but I don’t want to have to develop on 2 platforms.

The nodeJS server is so simple to implement, and it is already serving my jquery mobile app and I am now back to working on the data presentation code, rather than trying just to get the pages to display.

I did try again with the changes you suggested in your last post and manage to get it running, however, I then also discovered that ajax calls from javascript pages do not load at all. Also if I keep refreshing a page, there’s no guarantee that it will all display, sometimes images are missing, sometimes stylesheets ot javascript is not loaded.

It’s a shame as I have done so much this far, but it had to come to a point that I needed to move forward with the other parts of the project and hence the decision to call it quits with xojo.

Thanks again for your patience and help.

PeterC