Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[.Net] Unworldly.Engine GNDK


deathtaker26
 Share

Recommended Posts

So, I've been fixing up some stuff from unworldly, cropping out and breaking down what I can. This is the Unworldly.Engine Game Network Development Kit. Right now it's only in an alpha version, it does work, however there is no error checking or anything in its current state. You will need to add handling for disconnections and what not. I figured I'd release its current state as a reference for anyone using .Net Sockets to make an engine or whatever.

This is the basics of it, sorry for this crappy quality, the next video will be better, it's 4:30am, I don't feel like restarting it.

https://www.youtube.com/watch?v=UIAYsVmzqp0

And, here is the code for the test program.

This is in C#, you can use the library VB.Net as well, it's built for .Net…

Network_NewChat.cs [Event Handler "Plugin"]

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Unworldly.GNDK.System;
using Unworldly.GNDK.System.Interfaces;

namespace UnworldlyNetTest.Network_Events
{
   class Network_NewChat : Subscriber
   {

       public Network_NewChat(iObserver observer, string hook) : base(observer, hook) { }

       private string hk;
       private iObserver obs;

       public string Hook
       {
           get { return hk; }
           set { hk = value; }
       }

       public iObserver _Observer
       {
           get { return obs; }
           set { obs = value; }
       }

       public override void Run(dynamic[] args)
       {
           //Hook
           //Packet
           //Socket
           Packet packet = args[1];
           Socket socket = args[2];

           string message = packet.Data[0];

           Console.Write(socket.RemoteEndPoint.ToString() + ": " + message);
       }
   }
}

```Program.cs [The program]```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unworldly.GNDK.System;

using UnworldlyNetTest.Network_Events;

namespace UnworldlyNetTest
{
   class Program
   {
       public static Network network = new Network();

       static void Main(string[] args)
       {
           Console.WriteLine("Is this a client or server? C/S");

           string cmd = Console.ReadLine();
           if (cmd == "C" || cmd == "c")
           {
               network.Connect("127.0.0.1", 25536);
               Console.WriteLine("Connected to unworldly host!");
           }
           else if (cmd == "S" || cmd == "s")
           {
               network.CreateHost(25536);
               Console.WriteLine("Unworldly Host Created!");
           }
           else
           {
               Console.WriteLine("Invalid command, now exiting!");
               return;
           }

           //Attach Network Events
           Network_NewChat ChatEvent = new Network_NewChat(network.NetworkObserver, "chat");

           //Send Chat Messsage
           cmd = Console.ReadLine();

           while (cmd != "//quit")
           {
               Packet packet = new Packet(new dynamic[1] { cmd }, "chat");
               network.Send(packet);
               cmd = Console.ReadLine();
           }
       }
   }
}

```My github stuff isn't working at the moment… I'll try to fix the github tomorrow.
Link to comment
Share on other sites

> You are using some really weird naming. Network_NewChat and iObserver? Really? And GNDK is weird, I thought it was -insertsomethingthatbeginswithglikegnomes- Native Development Kit :D @[member="Crest"], I am sure you can do it better.
>
> NetworkNewChat and IObserver please.

The NewChat was event and an example, second there is nothing wrong with the namespace for the kit…. Observers are named after the Observer Programming pattern the I in front of it represents that it's an interface, if you don't understand the procedures for naming classes and variables in Object Orientated Programming, I suggest learning it.

It's like why we start Private variables with an Underscore.... Private string _pVariable....
Link to comment
Share on other sites

I did some reading up, I hadn't realized that I used a lowercase i in my interface. The AutoComplete corrected it when I went to instantiate it. As for the Network_NewChat, this was an event and the Network_ was the header I using to define it as a network event. There is absolutely nothing wrong with that. Last but not least, there is absolutely nothing wrong with my namespace. The game Engine's namespace was "Unworldly.Engine" the Game Network Development Kit's Namespace was Unworldly.GNDK

Don't sound hostile when replying to posts as if you're better than any other developer here.
Link to comment
Share on other sites

I am not stating that I am better but just saying what pops in my head when I see things like this. You should stick to one naming standard, CamelCase, snake_case or whatever but please, don't mix them, it looks so weird.

Edit: Also, I did not said that GNDK is bad namespace, I was just having fun of it as Android NDK instantly popped in my head when I saw it.
Link to comment
Share on other sites

> I am not stating that I am better but just saying what pops in my head when I see things like this. You should stick to one naming standard, CamelCase, snake_case or whatever but please, don't mix them, it looks so weird.
>
> Edit: Also, I did not said that GNDK is bad namespace, I was just having fun of it as Android NDK instantly popped in my head when I saw it.

My coding conventions are to my own comfort, if you don't like them, deal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...