Real Software Forums

Communicating with my app via a socket
Page 1 of 1

Author:  MadDoc [ Sun Jan 27, 2013 10:27 am ]
Post subject:  Communicating with my app via a socket

I'm writing an application to help me manage my growing collection of retro game ROMs. I know there are lots of options and other programs out there that do this but I want to write my own.

My approach is to have a small 'server' app that runs continuously in the background. Its preferences can be accessed by clicking a taskbar or menubar icon. The server's role is to index all ROMs in a particular directory and populate a SQLite database with metadata. The server will also be in charge of launching (via the command line) the correct emulator for a chosen ROM.

A second application, the 'client' will be responsible for displaying the information about the ROMs (i.e. a visual browser) and for selecting which emulator to use to run it. I'm looking for the best way to communicate between the two. For instance, the client should be able to request all Super NES games currently indexed in the the 'platformer' genre and the server would return an XML formatted list that can be subsequently parsed. I'm looking for suggestions for the best approach to implement this. Although the server and my client will be written in Real Studio, I'm hoping that other people would be able to interface with the server (for instance from XBMC or Plex) using an API that I publish. This means that the format of communication needs to be a standard of some sort rather than a proprietary Real Software format (which is putting me off things like EasyTCPSocket).

I'm relatively new to networking so I don't want to start this project until I have a good idea of how to lay it out.

I'd really appreciate any advice people have.



Author:  p0wn3d [ Sun Jan 27, 2013 3:08 pm ]
Post subject:  Re: Communicating with my app via a socket

How about having the server stream the emulated rom to the client?

Author:  MadDoc [ Sun Jan 27, 2013 4:17 pm ]
Post subject:  Re: Communicating with my app via a socket

That's certainly a feature I'm considering implementing once I get the metadata scraping / managing side of things working. There will of course be issues of latency though (amongst many other technical hurdles!).

Author:  p0wn3d [ Sun Jan 27, 2013 4:57 pm ]
Post subject:  Re: Communicating with my app via a socket

I have been working on something similar over the last few months with the Boxee API but had to put to one side due to work commitments.

Author:  charonn0 [ Sun Jan 27, 2013 9:06 pm ]
Post subject:  Re: Communicating with my app via a socket

I would say that probably the easiest way to make your indexing app accessible over a socket would be to use a widely used data serialization format, RB supports XML and JSON so those would be good choices. Many, many other programming languages support one, the other or both of these formats, so if third-party clients are wanted, using one of these would make it much easier for the third parties.

As an example, here's a contrived JSON-based search protocol using a TCPSocket:
Dim sock As New TCPSocket
sock.Port = 50000
sock.Address = ""
Dim query As New JSONItem
query.Value("Command") = "Search"
query.Value("Parameter") = "Ocarina"
Dim data As String = query.ToString
sock.Write(data + EndOfLine.Windows)

The other side of the TCPSocket (the indexer/server) would receive a string that looked like this:

The indexer/server would get the string and then convert it back into a JSONItem, determine how to respond, and then respond with another JSONItem:

Sub DataAvailable()
'In the TCPSocket's DataAvailable event
Dim data As String = Me.ReadAll

Dim query As New JSONItem(data)
If query.HasName("Command") Then
Select Case query.Value("Command").StringValue
Case "Search"
Dim result As JSONItem = SomeFunctionThatReturnsJSONResults(query.Value("Parameter"))
If result <> Nil Then
Dim response As New JSONItem
response.Value("Number of results") = result.Count
response.Value("Original Query") = query.Value("Parameter")
response.Value("Results") = result
data = response.ToString
Me.Write(data + EndOfLine.Windows)
End If

Case "Add"

Case "Delete"

End Select
End If
End Sub

A successful "Search" command might be serialized to the socket something like this:

{"Number of results":1,"Original Query":"Ocarina","Results":{"Title":"Ocarina of Time","Location":"C:\\ROMs\\OoT\\Oot.rom"}}

The client would receive this in its DataAvailable event, and handle it much like the server did, just handling the other side of the conversation.

Author:  MadDoc [ Mon Jan 28, 2013 2:21 am ]
Post subject:  Re: Communicating with my app via a socket

charonn0: That is incredibly useful. Thank you ever so much! Gives me a good foundation to explore

Author:  p0wn3d [ Mon Jan 28, 2013 5:48 am ]
Post subject:  Re: Communicating with my app via a socket


charonn0 that is very neat I like it

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group