User Tag List

Results 1 to 7 of 7

Thread: Lacewing Server in C

  1. #1
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleInstall Creator ProUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Lacewing Server in C

    I'm trying to make a lacewing server with the 0.2.6 library in C however the MMF Client (lacewing extention build #20) isn't connecting to the server. I've created a quick Lacewing server in MMF and it works perfectly fine. I'm pretty certain its my C code. Here's what I have for a server currently:

    Code:
    // Lacewing server test...
    //
    #include "StdAfx.h"
    #include <Lacewing.h>
    #include <stdio.h>
    #include <string.h>
    #include "functions.h"
    
    void on_connect(lw_server* server, lw_server_client* client);
    void on_disconnect(lw_server* server, lw_server_client* client);
    void on_data(lw_server* server, lw_server_client* client, char* data, long size);
    void on_error(lw_server* server, lw_error* error);
    
    int main()
    {
        lw_eventpump* pump = lw_eventpump_new();
        lw_server* server = lw_server_new(pump);
     
        lw_server_onconnect(server, on_connect);
        lw_server_ondisconnect(server, on_disconnect);
        lw_server_onreceive(server, on_data);
        lw_server_onerror(server, on_error);
        lw_server_host(server, 7357);
       
        lw_eventpump_start_event_loop(pump);
     
        lw_server_delete(server);
        lw_eventpump_delete(pump);
        return 0;
    }
    
    void on_connect(lw_server* server, lw_server_client* client)
    {
        printf("Client %d connecting with id %p\n", client, lw_server_client_address(client));
    }
    
    void on_disconnect(lw_server* server, lw_server_client* client)
    {
        printf("Client %d has disconnected...", client);
    }
    
    void on_data(lw_server* server, lw_server_client* client, char* data, long size)
    {
        display_packet(&data[0], *(short*)&data[1] + 2);
    }
    
    void on_error(lw_server* server, lw_error* error)
    {
        printf("Error: %s\n", error);
    }
    I created a function to print out the packet data on screen. The server console outputs the following:
    Code:
    Client 7208996 connecting with id 00B84B60
    (0000) 00 00                                           ..
    
    (0000) 00 0B 00 72 65 76 69 73 69 6F 6E 20 33          ...revision 3
    I've been unable to find much documentation on the Lacewing Library for hosting game servers. I'm hoping someone here can help.

    Many thanks.

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The Lacewing server classes have nothing to do with the Relay server classes. You need to use C++ with 0.2.6 to use the Relay classes - there's no C version of them.

    I'm hosting the old 0.2.6 documentation here:
    http://www.lb-stuff.com/Temp/lwd/docs/relayserver/

    I also have some working code that hosts a Relay server:
    https://github.com/LB--/lLacewing-Se...aster/Main.cpp
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleInstall Creator ProUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    D'oh. Thanks for the info!

  4. #4
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,848
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    It should be pointed out, I suppose, that Lacewing Relay Client uses liblacewing 0.2.6, and Bluewing uses liblacewing 0.5.0, although the format of messages is the same (spec here).

  5. #5
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleInstall Creator ProUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LB View Post
    The Lacewing server classes have nothing to do with the Relay server classes. You need to use C++ with 0.2.6 to use the Relay classes - there's no C version of them.

    I'm hosting the old 0.2.6 documentation here:
    http://www.lb-stuff.com/Temp/lwd/docs/relayserver/

    I also have some working code that hosts a Relay server:
    https://github.com/LB--/lLacewing-Se...aster/Main.cpp
    I've started making server code based on your relay server code. I was wondering if I needed to worry about making the client data stores (created structures for the clients inventory and so on) thread safe?

    Thanks.

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The only threadsafe function in liblacewing is the event pump post member function, but I don't see why you would be using threads with a library designed to make single-threaded servers efficient. If you find that the server really is being capped out in its processing power, maybe then you might possibly consider multithreading, but you're best off just staying single-threaded

  7. #7
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleInstall Creator ProUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Oh, I had assumed that the code you provided was threaded. So was worried about the threads causing issues with the global data. It not being threaded makes life easier.

    Thanks.

Similar Threads

  1. Basic Lacewing server/Serveur Lacewing basique
    By samcool_129 in forum File Archive
    Replies: 4
    Last Post: 24th April 2013, 06:50 AM
  2. Lacewing Web Server
    By DJFuego in forum Lacewing
    Replies: 1
    Last Post: 11th March 2011, 06:17 PM
  3. Lacewing-Server-Extension
    By Pharanygitis in forum Lacewing
    Replies: 2
    Last Post: 9th March 2011, 11:31 AM
  4. Lacewing server? Just a little help.
    By Gibbon in forum Lacewing
    Replies: 12
    Last Post: 16th December 2010, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •