| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Collections.Generic;
- namespace UNet
- {
- internal class USocketManager
- {
- private readonly Dictionary<IntPtr, USocket> sockets = new Dictionary<IntPtr, USocket>();
- public void Add(IntPtr peerPtr, USocket uSocket)
- {
- this.sockets.Add(peerPtr, uSocket);
- }
- public void Remove(IntPtr peerPtr)
- {
- this.sockets.Remove(peerPtr);
- }
- public bool ContainsKey(IntPtr peerPtr)
- {
- if (this.sockets.ContainsKey(peerPtr))
- {
- return true;
- }
- return false;
- }
- public USocket this[IntPtr peerPtr]
- {
- get
- {
- if (!this.sockets.ContainsKey(peerPtr))
- {
- throw new KeyNotFoundException("No Peer Key");
- }
- return this.sockets[peerPtr];
- }
- }
- }
- }
|