mirror of
https://github.com/opensim/opensim.git
synced 2026-05-16 19:56:04 +08:00
89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using libsecondlife.Packets;
|
|
using OpenSim.Framework.Interfaces;
|
|
using OpenSim.Framework;
|
|
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>();
|
|
protected uint serverPort;
|
|
|
|
public PacketServer(OpenSimNetworkHandler networkHandler, uint port)
|
|
{
|
|
_networkHandler = networkHandler;
|
|
this.serverPort = port;
|
|
_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, this._localWorld, assetCache, this, inventoryCache, authenticateSessionsClass, serverPort);
|
|
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);
|
|
}
|
|
}
|
|
}
|