[Release] Super-Basic Server Base

08/16/2011 06:48 .Kinshi#76
I'm curious as to what people think of this source.

Any comments, questions, concerns?
08/16/2011 09:06 Spirited#77
Quote:
Originally Posted by .Kinshi View Post
I'm curious as to what people think of this source.

Any comments, questions, concerns?
I have a concern that your packet handler is less efficient than just using a switch. I talked to Hybrid about it too and he said the same thing. I would double check on if that's an appropriate method.
08/17/2011 01:50 .Kinshi#78
Quote:
Originally Posted by Fаng View Post
I have a concern that your packet handler is less efficient than just using a switch. I talked to Hybrid about it too and he said the same thing. I would double check on if that's an appropriate method.
Hmm, I had a discussion with Unknownone about it a long long time ago (I've been using this way for a long ass time :P) and he said it was a pretty efficient way to do it.
I might do some further testing.
08/17/2011 07:14 Spirited#79
Quote:
Originally Posted by .Kinshi View Post
Hmm, I had a discussion with Unknownone about it a long long time ago (I've been using this way for a long ass time :P) and he said it was a pretty efficient way to do it.
I might do some further testing.
Well, if you think about it, a switch statement would be much simpler. I can see where a dictionary would be more efficient if the switch contained more than 50 cases, but I can't see it being more efficient with less than 30. (Either way, it's just checking values- but a switch is simpler than a dictionary and possibly more efficient).

Definitely do some testing. As I said, it's just a concern. I'd be interested in which is faster. I'm too busy to work with anything anymore (co related).
08/17/2011 07:31 BaussHacker#80
This is how you find the packet processor:
Code:
public TValue this[TKey key]
{
    get
    {
        int index = this.FindEntry(key);
        if (index >= 0)
        {
            return this.entries[index].value;
        }
        ThrowHelper.ThrowKeyNotFoundException();
        return default(TValue);
    }
    set
    {
        this.Insert(key, value, false);
    }
}
Code:
private int FindEntry(TKey key)
{
    if (key == null)
    {
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
    }
    if (this.buckets != null)
    {
        int num = this.comparer.GetHashCode(key) & 0x7fffffff;
        for (int i = this.buckets[num % this.buckets.Length]; i >= 0; i = this.entries[i].next)
        {
            if ((this.entries[i].hashCode == num) && this.comparer.Equals(this.entries[i].key, key))
            {
                return i;
            }
        }
    }
    return -1;
}
Where a switch case will just take x from y.

Imagine 1000 entries in your dictionary.
What seems faster in your own opinion, looping through all the entries or taking x from y?

A switch case would be much faster IMO.
08/19/2011 00:18 _tao4229_#81
Quote:
Originally Posted by BaussHacker View Post
This is how you find the packet processor:
Where a switch case will just take x from y.

Imagine 1000 entries in your dictionary.
What seems faster in your own opinion, looping through all the entries or taking x from y?

A switch case would be much faster IMO.
That doesn't loop through all the entries in the dictionary.
It's a hashtable.

Most of the time it's a single lookup to find the entry, unless two entries have the same hash (mod the number of buckets) in which it then loops through to find the specific entry.

For 1000 entries it's likely to find it in one or very few tries (depending on the amount of "buckets" and the distribution of the hash algorithm).
08/19/2011 17:04 stefans94#82
I got this problem,
I really want to learn C# so i thought about using this source, but i can't even run it XD
Quote:
Locating source for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'. Checksum: MD5 {55 76 a3 37 12 d7 84 65 c8 2 a9 9c 87 9f ce ae}
The file 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs' does not exist.
Looking in script documents for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'...
Looking in the projects for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'.
The file was not found in a project.
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs.
The debugger could not locate the source file 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'
08/20/2011 00:44 _DreadNought_#83
Quote:
MySqlEn gine.cs
theres a space in the name.
08/21/2011 20:14 .Kinshi#84
Quote:
Originally Posted by stefans94 View Post
I got this problem,
I really want to learn C# so i thought about using this source, but i can't even run it XD
Weird it looks like it's looking for the source of my KinSocket dll.
I don't know why it would be doing that :S