Client Login Area
Main Menu
Results 1 to 6 of 6

Thread: C# Sockets/Packets Help

  1. #1
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default C# Sockets/Packets Help

    I have gotten most errors fixed except for one. It says that Packet does not exsist in the current context.


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Sockets;
    
    namespace Eclipse_5._0
    {
        class PacketHandler
        {
            #region Packet Constructors
            private delegate void PacketDelegate(int Index, byte[] Data);
            private PacketDelegate[] Packet;
    
            public PacketHandler()
            {
                Packet(Enumerations.ClientPackets.CAddChar) = HandleAddChar;
            }
            #endregion
    
            #region Packet Methods
            public void Handledata(int Index, byte[] Data, int MsgType)
            {
                ByteBuffer Buff = new ByteBuffer();
                Buff.WriteBytes(Data);
                if (MsgType < 0)
                {
                    return;
                }
                if (MsgType >= (int)Enumerations.ClientPackets.CQuit)
                {
                    return;
                }
                Packet(MsgType).Invoke(Index, Buff.ReadBytes(Buff.Length()));
                Buff.Dispose();
            }
    
            public void HandleNewAccount(int Index, byte[] Data)
            {
                //TODO: Add New Player Account File.
            }
    
            public void HandleAddChar(int Index, byte[] Data)
            {
                //TODO: Add New Character to Player Account File.
            }
            #endregion
        }
    }

    here is some of the original code in VB.net
    Code:
    #Region "Packet Constructors"
        Private Delegate Sub PacketDelegate(ByVal Index As Integer, ByVal Data() As Byte)
        Private Packet() As PacketDelegate
        Public Sub New()
            ReDim Packet(PacketEnumServer.PackEnd)
            Packet(PacketEnumServer.PackNewsRequest) = AddressOf HandleNewsRequest
            Packet(PacketEnumServer.PackRegisterRequest) = AddressOf HandleRegisterRequest
        End Sub
    #End Region
    #Region "Packet Methods"
        Public Sub HandleData(ByVal Index As Integer, ByVal Data() As Byte, ByVal MsgType As Integer)
            Dim Buff As ByteBuffer = New ByteBuffer()
            Buff.WriteBytes(Data)
            If MsgType < 0 Then
                Exit Sub
            End If
            If MsgType >= PacketEnumServer.PackEnd Then
                Exit Sub
            End If
            Packet(MsgType).Invoke(Index, Buff.ReadBytes(Buff.Length))
            Buff.Dispose()
        End Sub
    Living to Kill, Killing to Live

    Come learn more about Project NLIXD!

  2. #2
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    come one some one must know how to help me with this....
    Living to Kill, Killing to Live

    Come learn more about Project NLIXD!

  3. #3
    ASPnix Administration Chris's Avatar
    Join Date
    October 11, 2008
    Location
    Denver, Colorado
    Posts
    802

    Default

    I would recommend going to a dedicated programming forum. Like the Microsoft developer forums. You may get better results there.
    Christopher York
    ASPnix Administration Team
    www.aspnix.com

  4. #4
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    Well after hours upon hours and days upon days I found something that would work instead of the regular system.net.sockets. Its a third party library but its really nice. So I'm going to give that a try.
    Living to Kill, Killing to Live

    Come learn more about Project NLIXD!

  5. #5
    ASPnix Administration Chris's Avatar
    Join Date
    October 11, 2008
    Location
    Denver, Colorado
    Posts
    802

    Default

    I would recommend the use of 3rd party libs. Most are built better, and require less work, however may have a cost overhead.
    Christopher York
    ASPnix Administration Team
    www.aspnix.com

  6. #6
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    I am. I'm using the Lidgren Networking Library. Its the newest and most up to date 3rd party control I know. I've almost got the server set up how I would like it. Then it will be to work on the client lol
    Living to Kill, Killing to Live

    Come learn more about Project NLIXD!

Posting Permissions

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