Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[WIP] Flex.Net

Discussion in 'Multiplayer' started by lorigio, Jul 16, 2013.

  1. lorigio

    lorigio

    Joined:
    Jul 13, 2013
    Posts:
    2
    Hi!
    Flex.Net is a framework to make simple and flexible server.
    You must write only write server response to a DLL and let Flex.Net handle clients requests.

    Example of a DLL
    Code (csharp):
    1. public class PacketHandler
    2. {  
    3.     public Mysql MysqlConn;
    4.     public PacketHandler()
    5.     {
    6.         MysqlConn = new Mysql();
    7.         MysqlConn.Connect("127.0.0.1", 3306, "root", "123456", "unity");
    8.  
    9.         MysqlConn.GetClient();      
    10.     }
    11.  
    12.     public MethodResponse LOGIN(object username, object password)
    13.     {
    14.         bool response = false;
    15.  
    16.         DataRow Row = MysqlConn.ReadDataRow("SELECT * FROM users where username = '" + username + "' AND password = '" + password + "'");
    17.  
    18.         MethodResponse MethodResponse = new MethodResponse(false); //true if you want to send response to all clients
    19.         if (Row != null)
    20.         {
    21.             response = true;
    22.             MethodResponse.AddData((Convert.ToInt32(response)).ToString());
    23.             MethodResponse.AddData(Row["id"].ToString());
    24.         }
    25.         else
    26.             MethodResponse.AddData((Convert.ToInt32(response)).ToString());
    27.  
    28.  
    29.         return MethodResponse;
    30.     }
    31.  
    32.     public MethodResponse LIST_CHARS(object user_id)
    33.     {
    34.         DataTable Table;
    35.  
    36.         Table = MysqlConn.ReadDataTable("SELECT * FROM characters where user_id = '" + user_id + "'");
    37.  
    38.  
    39.         if (Table != null)
    40.         {
    41.             MethodResponse MethodResponse = new MethodResponse(false);
    42.             foreach (DataRow Row in Table.Rows)
    43.             {
    44.                 MethodResponse.AddData(Row["char_name"].ToString());
    45.             }
    46.             return MethodResponse;
    47.         }
    48.         return null;
    49.     }
    50. }
    Screenshot:




    If you just add a code like this
    Code (csharp):
    1. public class WebserviceHandler : IWebservice
    2. {
    3.     public int GetCpu()
    4.     {  
    5.         return (int)Math.Round(PacketHandler.cpuCounter.NextValue(), 0);
    6.     }
    7. }
    8.  
    9. [ServiceContract]
    10. public interface IWebservice
    11. {    
    12.     [OperationContract]
    13.     int GetCpu();
    14. }
    you can have your own server panel and display what you want

    Screenshot:



    Let me know what do you think and how to improve it. Thanks
     
    Last edited: Jul 16, 2013
  2. eskimojoe

    eskimojoe

    Joined:
    Jun 4, 2012
    Posts:
    1,440
    Any URL?

    Flex.net goes to some search engine ste.
     
  3. lorigio

    lorigio

    Joined:
    Jul 13, 2013
    Posts:
    2
    Flex.Net is the name of Application not an url