/// <summary> /// Register an event handler /// </summary> /// <remarks>Use PacketType.Default to fire this event on every /// incoming packet</remarks> /// <param name="packetType">Packet type to register the handler for</param> /// <param name="eventHandler">Callback to be fired</param> public void RegisterEvent(PacketType packetType, NetworkManager.PacketCallback eventHandler) { lock (_EventTable) { if (_EventTable.ContainsKey(packetType)) _EventTable[packetType] += eventHandler; else _EventTable[packetType] = eventHandler; } }
public static void DisconnectHandler(NetworkManager.DisconnectType type, string message) { if (type == NetworkManager.DisconnectType.NetworkTimeout) { Console.WriteLine("Network connection timed out, disconnected"); } else if (type == NetworkManager.DisconnectType.ServerInitiated) { Console.WriteLine("Server disconnected us: " + message); } }
public void RegisterLoginResponseCallback(NetworkManager.LoginResponseCallback callback, string[] options) { return; }
/// <summary> /// /// </summary> /// <param name="client">Reference to the GridClient object</param> /// <param name="address">IPEndPoint of the simulator</param> /// <param name="handle">handle of the simulator</param> public Simulator(GridClient client, IPEndPoint address, ulong handle) : base(address) { Client = client; Handle = handle; Network = Client.Network; PacketArchive = new IncomingPacketIDCollection(Settings.PACKET_ARCHIVE_SIZE); InBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); OutBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); if (client.Settings.STORE_LAND_PATCHES) { Terrain = new TerrainPatch[16 * 16]; WindSpeeds = new Vector2[16 * 16]; } }
private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { if (InterpolationTimer != null) { InterpolationTimer.Dispose(); InterpolationTimer = null; } }
public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { if (OnDisconnected != null) { OnDisconnected(this, EventType.DISCONNECTED); } }
/// <summary> /// /// </summary> /// <param name="client">Reference to the GridClient object</param> /// <param name="address">IPEndPoint of the simulator</param> /// <param name="handle">handle of the simulator</param> public Simulator(GridClient client, IPEndPoint address, ulong handle) : base(address) { Client = client; Handle = handle; Network = Client.Network; PacketArchive = new IncomingPacketIDCollection(Settings.PACKET_ARCHIVE_SIZE); InBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); OutBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); }
/// <summary> /// Group Management Routines, Methods and Packet Handlers /// </summary> /// <param name="client">A reference to the current <seealso cref="GridClient"/> instance</param> public GroupManager(LoggerInstance log, NetworkManager network, AgentManager self) { Log = log; Network = network; Self = self; GroupMembersCaches = new InternalDictionary<UUID, Dictionary<UUID, GroupMember>>(); GroupMembersRequests = new List<UUID>(); GroupRolesCaches = new InternalDictionary<UUID, Dictionary<UUID, GroupRole>>(); GroupRolesRequests = new List<UUID>(); GroupRolesMembersCaches = new InternalDictionary<UUID, List<KeyValuePair<UUID, UUID>>>(); GroupRolesMembersRequests = new List<UUID>(); GroupName2KeyCache = new InternalDictionary<UUID, string>(); Network.RegisterEventCallback("AgentGroupDataUpdate", new Caps.EventQueueCallback(AgentGroupDataUpdateHandler)); Network.RegisterCallback(PacketType.AgentDropGroup, new NetworkManager.PacketCallback(AgentDropGroupHandler)); Network.RegisterCallback(PacketType.GroupTitlesReply, new NetworkManager.PacketCallback(GroupTitlesHandler)); Network.RegisterCallback(PacketType.GroupProfileReply, new NetworkManager.PacketCallback(GroupProfileHandler)); Network.RegisterCallback(PacketType.GroupMembersReply, new NetworkManager.PacketCallback(GroupMembersHandler)); Network.RegisterCallback(PacketType.GroupRoleDataReply, new NetworkManager.PacketCallback(GroupRoleDataHandler)); Network.RegisterCallback(PacketType.GroupRoleMembersReply, new NetworkManager.PacketCallback(GroupRoleMembersHandler)); Network.RegisterCallback(PacketType.GroupActiveProposalItemReply, new NetworkManager.PacketCallback(GroupActiveProposalItemHandler)); Network.RegisterCallback(PacketType.GroupVoteHistoryItemReply, new NetworkManager.PacketCallback(GroupVoteHistoryItemHandler)); Network.RegisterCallback(PacketType.GroupAccountSummaryReply, new NetworkManager.PacketCallback(GroupAccountSummaryHandler)); Network.RegisterCallback(PacketType.CreateGroupReply, new NetworkManager.PacketCallback(CreateGroupReplyHandler)); Network.RegisterCallback(PacketType.JoinGroupReply, new NetworkManager.PacketCallback(JoinGroupReplyHandler)); Network.RegisterCallback(PacketType.LeaveGroupReply, new NetworkManager.PacketCallback(LeaveGroupReplyHandler)); Network.RegisterCallback(PacketType.UUIDGroupNameReply, new NetworkManager.PacketCallback(UUIDGroupNameReplyHandler)); Network.RegisterCallback(PacketType.EjectGroupMemberReply, new NetworkManager.PacketCallback(EjectGroupMemberReplyHandler)); Network.RegisterCallback(PacketType.GroupNoticesListReply, new NetworkManager.PacketCallback(GroupNoticesListReplyHandler)); }
//public bool SendPings; //public int NetworkTickInterval; //public int PingInterval; //public bool SendAgentUpdates; //public int SimulatorTimeout; //public bool EnableCaps; #endregion /// <summary> /// /// </summary> /// <param name="client">Reference to the GridClient object</param> /// <param name="address">IPEndPoint of the simulator</param> /// <param name="handle">handle of the simulator</param> public Simulator(LoggerInstance log, NetworkManager network, IPEndPoint address, ulong handle) : base(address) { //Client = client; Log = log; Handle = handle; Network = network; PacketArchive = new IncomingPacketIDCollection(Settings.PACKET_ARCHIVE_SIZE); InBytes = new Queue<long>(Network.StatsQueueSize); OutBytes = new Queue<long>(Network.StatsQueueSize); }
private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { if (RebakeScheduleTimer != null) { RebakeScheduleTimer.Dispose(); RebakeScheduleTimer = null; } if (AppearanceThread != null) { if (AppearanceThread.IsAlive) { AppearanceThread.Abort(); } AppearanceThread = null; AppearanceThreadRunning = 0; } }
/// <summary> /// Unregister an event handler /// </summary> /// <param name="packetType">Packet type to unregister the handler for</param> /// <param name="eventHandler">Callback to be unregistered</param> public void UnregisterEvent(PacketType packetType, NetworkManager.PacketCallback eventHandler) { lock (_EventTable) { if (_EventTable.ContainsKey(packetType) && _EventTable[packetType] != null) _EventTable[packetType] -= eventHandler; } }
/// <summary> /// Constructor /// </summary> /// <param name="client">Instance of GridClient object to associate with this GridManager instance</param> public GridManager(LoggerInstance log, NetworkManager network) { Log = log; Network = network; //Network.RegisterCallback(PacketType.MapLayerReply, MapLayerReplyHandler); Network.RegisterCallback(PacketType.MapBlockReply, MapBlockReplyHandler); Network.RegisterCallback(PacketType.MapItemReply, MapItemReplyHandler); Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, TimeMessageHandler); Network.RegisterCallback(PacketType.CoarseLocationUpdate, CoarseLocationHandler); Network.RegisterCallback(PacketType.RegionIDAndHandleReply, RegionHandleReplyHandler); }
/// <summary>Default constructor</summary> public AgentMovement(LoggerInstance log, AgentManager self, NetworkManager network) { Log = log; Network = network; Self = self; Camera = new AgentCamera(); updateInterval = Settings.DEFAULT_AGENT_UPDATE_INTERVAL; updateTimer = new Timer(new TimerCallback(UpdateTimer_Elapsed), null, Settings.DEFAULT_AGENT_UPDATE_INTERVAL, Settings.DEFAULT_AGENT_UPDATE_INTERVAL); }
private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { CleanupTimer(); }
/// <summary> /// Internal constructor /// </summary> /// <param name="client">A reference to the GridClient Object</param> internal FriendsManager(LoggerInstance log, NetworkManager network, InventoryManager inventory, AgentManager self, AvatarManager avatars) { Log = log; Network = network; Inventory = inventory; Self = self; Avatars = avatars; Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnect); Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames); Self.OnInstantMessage += new AgentManager.InstantMessageCallback(MainAvatar_InstantMessage); Network.RegisterCallback(PacketType.OnlineNotification, OnlineNotificationHandler); Network.RegisterCallback(PacketType.OfflineNotification, OfflineNotificationHandler); Network.RegisterCallback(PacketType.ChangeUserRights, ChangeUserRightsHandler); Network.RegisterCallback(PacketType.TerminateFriendship, TerminateFriendshipHandler); Network.RegisterCallback(PacketType.FindAgent, OnFindAgentReplyHandler); Network.RegisterLoginResponseCallback(new NetworkManager.LoginResponseCallback(Network_OnLoginResponse), new string[] { "buddy-list" }); }
// FIXME: Create a class-level appearance thread so multiple threads can't be launched /// <summary> /// Default constructor /// </summary> /// <param name="client">This agents <seealso cref="OpenMetaverse.GridClient"/> Object</param> /// <param name="assets">Reference to an AssetManager object</param> public AppearanceManager(LoggerInstance log, NetworkManager network, InventoryManager inventory, AssetManager assets, ObjectManager objects, AgentManager self) { Log = log; Network = network; Inventory = inventory; Assets = assets; Self = self; Objects = objects; // Initialize AgentTextures to zero UUIDs for (int i = 0; i < AgentTextures.Length; i++) AgentTextures[i] = UUID.Zero; Network.RegisterCallback(PacketType.AgentWearablesUpdate, new NetworkManager.PacketCallback(AgentWearablesUpdateHandler)); Network.RegisterCallback(PacketType.AgentCachedTextureResponse, new NetworkManager.PacketCallback(AgentCachedTextureResponseHandler)); Network.RegisterCallback(PacketType.RebakeAvatarTextures,new NetworkManager.PacketCallback(RebakeAvatarTexturesHandler)); Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected); }
void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { ParcelsDownloaded.Set(); }
public ClientDisconnectEventArgs(NetworkManager.DisconnectType type, string message) { this.type = type; this.message = message; }
private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { // Null out the cached fullName since it can change after logging // in again (with a different account name or different login // server but using the same GridClient object fullName = null; }
/// <summary> /// Default constructor /// </summary> public GridClient() { // Initialise SmartThreadPool when using mono if (Type.GetType("Mono.Runtime") != null) { WorkPool.Init(true); } // These are order-dependant Network = new NetworkManager(this); Settings = new Settings(this); Parcels = new ParcelManager(this); Self = new AgentManager(this); Avatars = new AvatarManager(this); Estate = new EstateTools(this); Friends = new FriendsManager(this); Grid = new GridManager(this); Objects = new ObjectManager(this); Groups = new GroupManager(this); Assets = new AssetManager(this); Appearance = new AppearanceManager(this); Inventory = new InventoryManager(this); Directory = new DirectoryManager(this); Terrain = new TerrainManager(this); Sound = new SoundManager(this); Throttle = new AgentThrottle(this); Stats = new OpenMetaverse.Stats.UtilizationStatistics(); }
void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { InitializeClient(!ShuttingDown); }
public SimDisconnectedEventArgs(Simulator simulator, NetworkManager.DisconnectType reason) { this.m_Simulator = simulator; this.m_Reason = reason; }
/// <summary> /// Default constructor /// </summary> public GridClient() { // These are order-dependant Network = new NetworkManager(this); Settings = new Settings(this); Parcels = new ParcelManager(this); Self = new AgentManager(this); Avatars = new AvatarManager(this); Friends = new FriendsManager(this); Grid = new GridManager(this); Objects = new ObjectManager(this); Groups = new GroupManager(this); Assets = new AssetManager(this); Appearance = new AppearanceManager(this, Assets); Inventory = new InventoryManager(this); Directory = new DirectoryManager(this); Terrain = new TerrainManager(this); Sound = new SoundManager(this); Throttle = new AgentThrottle(this); //if (Settings.ENABLE_INVENTORY_STORE) // InventoryStore = new Inventory(Inventory); //if (Settings.ENABLE_LIBRARY_STORE) // LibraryStore = new Inventory(Inventory); //Inventory.OnSkeletonsReceived += // delegate(InventoryManager manager) // { // if (Settings.ENABLE_INVENTORY_STORE) // InventoryStore.InitializeFromSkeleton(Inventory.InventorySkeleton); // if (Settings.ENABLE_LIBRARY_STORE) // LibraryStore.InitializeFromSkeleton(Inventory.LibrarySkeleton); // }; }
public DisconnectedEventArgs(NetworkManager.DisconnectType reason, String message) { this.m_Reason = reason; this.m_Message = message; }
/// <summary> /// /// </summary> /// <param name="client">Reference to the GridClient object</param> /// <param name="address">IPEndPoint of the simulator</param> /// <param name="handle">handle of the simulator</param> public Simulator(GridClient client, IPEndPoint address, ulong handle) : base(address) { Client = client; ipEndPoint = address; Handle = handle; Estate = new EstateTools(Client); Network = Client.Network; PacketArchive = new Queue<uint>(Settings.PACKET_ARCHIVE_SIZE); InBytes = new Queue<ulong>(Client.Settings.STATS_QUEUE_SIZE); OutBytes = new Queue<ulong>(Client.Settings.STATS_QUEUE_SIZE); }
public InventoryManager(GridClient client, NetworkManager network, AgentManager agents) { _Client = client; _Network = network; _Agents = agents; _Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, new NetworkManager.PacketCallback(UpdateCreateInventoryItemHandler)); _Network.RegisterCallback(PacketType.SaveAssetIntoInventory, new NetworkManager.PacketCallback(SaveAssetIntoInventoryHandler)); _Network.RegisterCallback(PacketType.BulkUpdateInventory, new NetworkManager.PacketCallback(BulkUpdateInventoryHandler)); _Network.RegisterCallback(PacketType.InventoryDescendents, new NetworkManager.PacketCallback(InventoryDescendentsHandler)); _Network.RegisterCallback(PacketType.FetchInventoryReply, new NetworkManager.PacketCallback(FetchInventoryReplyHandler)); _Network.RegisterCallback(PacketType.ReplyTaskInventory, new NetworkManager.PacketCallback(ReplyTaskInventoryHandler)); // Watch for inventory given to us through instant message _Agents.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage); // Register extra parameters with login and parse the inventory data that comes back List<string> options = new List<string>(5); if (Settings.ENABLE_INVENTORY_STORE) { options.Add("inventory-root"); options.Add("inventory-skeleton"); } if (Settings.ENABLE_LIBRARY_STORE) { options.Add("inventory-lib-root"); options.Add("inventory-lib-owner"); options.Add("inventory-skel-lib"); } if (Settings.ENABLE_INVENTORY_STORE || Settings.ENABLE_LIBRARY_STORE) { // Register extra parameters with login and parse the inventory data that comes back _Network.RegisterLoginResponseCallback( new NetworkManager.LoginResponseCallback(Network_OnLoginResponse), options.ToArray()); } }
public void disconnectedCallback(NetworkManager.DisconnectType reason, string message) { m_log.WarnFormat("[CONNECTION]: Disconnected{0}: Message:{1}",reason.ToString(), message); if (OnSimDisconnected != null) { OnSimDisconnected(reason, message); } }
/// <summary> /// /// </summary> /// <param name="client">Reference to the GridClient object</param> /// <param name="address">IPEndPoint of the simulator</param> /// <param name="handle">handle of the simulator</param> public Simulator(GridClient client, IPEndPoint address, ulong handle) : base(address) { Client = client; if (Client.Settings.POOL_PARCEL_DATA || Client.Settings.CACHE_PRIMITIVES) { SimulatorDataPool.SimulatorAdd(this); DataPool = SimulatorDataPool.GetSimulatorData(Handle); } Handle = handle; Network = Client.Network; PacketArchive = new IncomingPacketIDCollection(Settings.PACKET_ARCHIVE_SIZE); InBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); OutBytes = new Queue<long>(Client.Settings.STATS_QUEUE_SIZE); if (client.Settings.STORE_LAND_PATCHES) { Terrain = new TerrainPatch[16 * 16]; WindSpeeds = new Vector2[16 * 16]; } }
internal void SendPacketFinal(NetworkManager.OutgoingPacket outgoingPacket) { UDPPacketBuffer buffer = outgoingPacket.Buffer; byte flags = buffer.Data[0]; bool isResend = (flags & Helpers.MSG_RESENT) != 0; bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; // Keep track of when this packet was sent out (right now) outgoingPacket.TickCount = Environment.TickCount; #region ACK Appending int dataLength = buffer.DataLength; // Keep appending ACKs until there is no room left in the packet or there are // no more ACKs to append uint ackCount = 0; uint ack; while (dataLength + 5 < Packet.MTU && PendingAcks.TryDequeue(out ack)) { Utils.UIntToBytesBig(ack, buffer.Data, dataLength); dataLength += 4; ++ackCount; } if (ackCount > 0) { // Set the last byte of the packet equal to the number of appended ACKs buffer.Data[dataLength++] = (byte)ackCount; // Set the appended ACKs flag on this packet buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); } buffer.DataLength = dataLength; #endregion ACK Appending if (!isResend) { // Not a resend, assign a new sequence number uint sequenceNumber = (uint)Interlocked.Increment(ref Sequence); Utils.UIntToBytesBig(sequenceNumber, buffer.Data, 1); outgoingPacket.SequenceNumber = sequenceNumber; if (isReliable) { // Add this packet to the list of ACK responses we are waiting on from the server lock (NeedAck) NeedAck[sequenceNumber] = outgoingPacket; } } // Put the UDP payload on the wire AsyncBeginSend(buffer); }
/// <summary> /// Terminate any wait handles when the network layer disconnects /// </summary> private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { WearablesRequestEvent.Set(); WearablesDownloadedEvent.Set(); CachedResponseEvent.Set(); UpdateEvent.Set(); }