aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/PacketServer.cs
blob: dd8de4c610cc0b4c1bd09654c366e785ee56911a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using System.Net;
using System.Net.Sockets;
using OpenSim.Assets;

namespace OpenSim
{
    public class PacketServer
    {
        private OpenSimNetworkHandler _networkHandler;
        private IWorld _localWorld;
        public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
        public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();

        public PacketServer(OpenSimNetworkHandler networkHandler)
        {
            _networkHandler = networkHandler;
            _networkHandler.RegisterPacketServer(this);
        }

        public IWorld LocalWorld
        {
            set
            {
                this._localWorld = value;
            }
        }

        public virtual void ClientInPacket(uint circuitCode, Packet packet)
        {
            if (this.ClientThreads.ContainsKey(circuitCode))
            {
                ClientThreads[circuitCode].InPacket(packet);
            }
        }

        public virtual bool AddNewCircuitCodeClient(uint circuitCode)
        {
            return false;
        }

        public virtual void SendPacketToAllClients(Packet packet)
        {

        }

        public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
        {

        }

        public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
        {

        }

        public virtual void RegisterClientPacketHandlers()
        {
            
        }

        public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
        {
            ClientView newuser = new ClientView(epSender, useCircuit, this.ClientThreads, assetCache, this, inventoryCache, authenticateSessionsClass);
            this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
            this.ClientAPIs.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);

            return true;
        }

        public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
        {
            this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
        }

        public virtual void RemoveClientCircuit(uint circuitcode)
        {
            this._networkHandler.RemoveClientCircuit(circuitcode);
        }
    }
}