hedgewars/uFLNet.pas
author unc0rr
Wed, 22 Apr 2015 23:33:16 +0300
branchqmlfrontend
changeset 10898 f373838129c2
parent 10896 5a74923120d5
child 10900 6a805e822074
permissions -rw-r--r--
Some futher work on flib net client part
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10896
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     1
unit uFLNet;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     2
interface
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     3
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     4
procedure connectOfficialServer;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     5
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     6
procedure initModule;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     7
procedure freeModule;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     8
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
     9
implementation
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    10
uses SDLh;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    11
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    12
var sock: PTCPSocket;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    13
    fds: PSDLNet_SocketSet;
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    14
    buf: shortstring;
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    15
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    16
function netReader(data: pointer): LongInt; cdecl; export;
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    17
begin
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    18
end;
10896
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    19
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    20
procedure connectOfficialServer;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    21
var ipaddr: TIPAddress;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    22
begin
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    23
    if sock <> nil then
10896
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    24
        exit;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    25
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    26
    if SDLNet_ResolveHost(ipaddr, PChar('netserver.hedgewars.org'), 46631) = 0 then
10898
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    27
        sock:= SDLNet_TCP_Open(ipaddr);
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    28
f373838129c2 Some futher work on flib net client part
unc0rr
parents: 10896
diff changeset
    29
    callbackListenerThread:= SDL_CreateThread(@listener{$IFDEF SDL2}, 'ipcListener'{$ENDIF}, nil);
10896
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    30
end;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    31
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    32
procedure initModule;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    33
begin
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    34
    sock:= nil;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    35
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    36
    SDLNet_Init;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    37
    fds:= SDLNet_AllocSocketSet(1);
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    38
end;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    39
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    40
procedure freeModule;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    41
begin
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    42
end;
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    43
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents:
diff changeset
    44
end.