Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Information on designing protocols, HowTo's and such 1

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Ok here's the thing:

I am a member of a gaming league called (Total Assault Gaming). And the owner has a lot of money invested in a flash based chat, which works just great. But he wants it to be taken to the next level, which would be joining dedicated servers through the chat and wants me to help him create such a thing.

Now I was thinking that I could make a new protocol to make this work. Flash supports <A HREF=" So I figure that if I could pass the server information as a hyperlink then I could do that. So my idea of how to make this work is as follows:

1. I make a program that allows you to launch a dedicated server for a some game. For this example I'll use BattleField 2. But besides the program just launching the server it also goes to a webpage to add the server to a database which will look something like this: 3 columns; 1 for game name, 1 for server information, 1 for server name.

From this database the Flash chat will be updated when the database changes. So every game channel has all the active servers that people on tag create for that particular game.
But this is not where Delphi comes in, this is all Flash/PHP, which someone else is designing.

2. So now we have a link in the Flash chat on Internet Explorer (Doesn't need be working on anything else, not enough users for the other browsers on this gaming league).
So I figure if I could make a protocol like HTTP for example, but instead calling it TAG then I could do something like this> TAG://GAME:IP:pORT:pASSWORD.

3. Because the protocol is recognised by the users computer
my second program is started which reads the info in the protocol and launches the correct game to automatically join the server they selected in the Flash chat.

So basically what we are trying to achieve is that for example someone is in the BattleField 2 lobby and sees a server they want to join. They click on that server in the Flash chat which will put this protocol into action looking something like this:

TAG://BF2:85.236.101.56:16567:COOLDADDIO

My program is initiated and starts BattleField 2 up to join the server with the information:
IP: 85.236.101.56
PORT: 16567
PW: COOLDADDIO

So currently I am looking for information on how to create a new protocol like that. I can't really seem to find anything on how to do such a thing. Do you guys have information for me, or can you give me pointers to where to look? Maybe (hoping, dreaming, praying) even an example?

I know that this probably requires a lot of complex programming but it really would be great for the league!

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
No replies needed, I have found out how to do it.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
BobbaFet, it would be great if you could share what you've learnt with us. Maybe, it would be more appropriate further down the line to give us an overview of where you're at.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Actually, I was kind of shocked to find out how simple it is to do, almost the same as registering a file extension.

Except for that it's exactly the same as if it were a file extension.

Here is the code to install a URL Protocol:

Code:
procedure TForm1.InstallProtocol; // Installs TAG URL Protocol on computer
var
  Registry: TRegistry;
  ExeDir: String;
begin
  ExeDir := ExtractFilePath(ParamStr(0));
  Registry := TRegistry.Create;
  try
    Registry.RootKey := HKEY_CLASSES_ROOT;
    if Registry.OpenKey('tag', True) then
    begin
      Registry.WriteString('', 'URL:tag');
      Registry.WriteString('URL Protocol', '');
      Registry.CloseKey;
    end;
    if Registry.OpenKey('tag\DefaultIcon', True) then
    begin
      Registry.WriteString('', '"' + ParamStr(0) + '",0');
      Registry.CloseKey;
    end;
    if Registry.OpenKey('tag\shell\open\command', True) then
    begin
      Registry.WriteString('', '"' + ParamStr(0) + '" /protocol %1');
      Registry.CloseKey;
    end;
  finally
    Registry.Free;
  end;
end;

From this point on the entire link is sent as a parameter to the application ready for processing. So then I just use a lot of Pos(), Copy() and Delete() to rip all the parameters apart and get them ready for use.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
As Stretchwickster wanted some info more down the line here
is an update: Like I said before, it is only slightly
different from registering a file type, you point both to
an executable and both go in HKEY_CLASSES_ROOT. Just do not
add a dot infront of what you want. So for example you want
to use tag:// protocol (btw: the '//' is not mandatory,
just like with 'mailto:' but I like to use it to make it
look like a proper hyperlink). you will need an entry in
the HKEY_CLASSES_ROOT called 'tag'. In the 'tag' entry there
NEEDS to be the 'URL Protocol' signature. Then add what you
would normally add for registering a file type. See the
code posted above.

That code allows for a hyperlink like this one:
Code:
<a href="tag://bf2:111.111.111.111:23456:0">Click Me</a>
(my url protocol looks like this: tag://game:ip:port:askforpw (askforpw = true or false))
Clicking that link will cause to start up my program which
will then get the entire link as a parameter (%1). So %1
would become tag://bf2:111.111.111.111:23456:0.

IMPORTANT! Spaces in the link will cause you to have to use
%2, %3 etc etc. So make sure you take this into account as
it could mess up stuff.

Important Webbrowser stuff:
Works fine with Internet Explorer and Mozilla Firefox.
Doesn't work with Opera, which requires a new URL protocol
to be manually added (probably can add it through
programming but do not know how yet). Research on
TAGaming.com showed that 97,7% of the users used either
Firefox or IE, probably won't be much different anywhere
else. Not sure about Netscape Navigator. It is Mozilla
based like Firefox so it'll probably work, haven't tested
it yet.


[bobafett] BobbaFet [bobafett]

Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
faq102-5352
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top