Ejemplo n.º 1
0
        public void AddServerNode(IPEndPoint node, BlockingQueue<Message> storage)
        {
            lock (this)
            {
                NodeInfo nodeInfo = null;
                if (nodes.ContainsKey(node))
                {
                    nodeInfo = nodes[node];
                }

                if (nodeInfo == null)
                {
                    // connect to node
                    Socket socket;
                    try
                    {
                        socket = new Socket(AddressFamily.InterNetwork,
                                    SocketType.Stream, ProtocolType.Tcp);
                        socket.Connect(node);

                        TcpWorker worker = new TcpWorker(socket, storage);
                        new Thread(new ThreadStart(worker.run)).Start();
                        nodes[node] = new NodeInfo(socket, true);
                    }
                    catch (Exception)
                    {
                        Logger.getInstance().log("Failed to add server node: " + node.ToString(),
                                        LOGGING_NAME,
                                        Logger.Level.WARNING);
                        return;
                    }
                }
                else
                {
                    // mark node as server
                    nodeInfo.setIsServer(true);
                }
            }
        }
Ejemplo n.º 2
0
 public PollServiceWorkerThread(BaseHttpServer pSrv, int pTimeout)
 {
     m_request = new BlockingQueue<PollServiceHttpRequest>();
     m_server = pSrv;
     m_timeout = pTimeout;
 }
Ejemplo n.º 3
0
 public PollServiceWorkerThread(int pTimeout)
 {
     m_request = new BlockingQueue<PollServiceHttpRequest>();
     m_timeout = pTimeout;
 }
Ejemplo n.º 4
0
        public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat)
        {
            m_world = world;
            m_clientThreads = clientThreads;
            m_assetCache = assetCache;
            m_gridServer = gridServer;
            m_application = application;
            m_inventoryCache = inventoryCache;
            m_sandboxMode = sandboxMode;
            m_child = child;
            m_regionData = regionDat;

            OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request");
            cirpack = initialcirpack;
            userEP = remoteEP;
            if (m_gridServer.GetName() == "Remote")
            {
                this.startpos = ((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos;
            }
            else
            {
                this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 15.0f); // new LLVector3(128.0f, 128.0f, 60f);
            }
            PacketQueue = new BlockingQueue<QueItem>();

            this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
            AckTimer = new System.Timers.Timer(500);
            AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
            AckTimer.Start();

            this.RegisterLocalPacketHandlers();

            ClientThread = new Thread(new ThreadStart(AuthUser));
            ClientThread.IsBackground = true;
            ClientThread.Start();
        }
 SimilarItemsWorker(int number, BlockingQueue<long[]> itemIDBatches, BlockingQueue<List<SimilarItems>> results,
     AtomicInteger numActiveWorkers) {
   this.number = number;
   this.itemIDBatches = itemIDBatches;
   this.results = results;
   this.numActiveWorkers = numActiveWorkers;
 }
 Output(BlockingQueue<List<SimilarItems>> results, SimilarItemsWriter writer, AtomicInteger numActiveWorkers) {
   this.results = results;
   this.writer = writer;
   this.numActiveWorkers = numActiveWorkers;
 }
Ejemplo n.º 7
0
 private object[] Proxy(ISender sender,int maxResultsToWait, string method, object[] args) {
   BlockingQueue q = new BlockingQueue();
   args = AdrXmlRpcConverter.XmlRpc2AdrParams(args);
   _rpc.Invoke(sender, q, method, args);
   ArrayList allValues = new ArrayList();
   int counter = 0;
   ISender rsSender = null;
   try {
     do {
       RpcResult rpcRs = (RpcResult)q.Dequeue();
       rsSender = rpcRs.ResultSender;  //get it before exception thrown
       object val = rpcRs.Result;
       Debug.WriteLine(string.Format("Original Result: {0}", val));
       object xmlrpc_val = AdrXmlRpcConverter.Adr2XmlRpc(val); //conversion in here
       counter++;
       allValues.Add(xmlrpc_val);
     } while (maxResultsToWait < 0 ? true : (counter < maxResultsToWait));
   } catch (Exception e) {
     Debug.WriteLine(e);
     string s = string.Empty;
     if (e is AdrException) {
       if (rsSender != null) {
         s = AdrXmlRpcConverter.Adr2XmlRpc(rsSender) as string;
       }
     }
     if (e is InvalidOperationException) {
       /*
        * this is what we expect at the end of Dequeuing, so just return what we've gotten so far
        * it could be an empty array
        */
       return allValues.ToArray();
     }
     Exception new_e = AdrXmlRpcConverter.Adr2XmlRpc(e) as Exception;
     throw new Exception(new_e.Message + 
       (s.Equals(string.Empty) ? string.Empty : string.Format("thrown by: {0}", s)));
   } finally {
     if (!q.Closed) {
       q.Close();
     }
   }
   return allValues.ToArray();
 }
Ejemplo n.º 8
0
 public void setQueue(BlockingQueue<Message> q)
 {
     queue = q;
 }
Ejemplo n.º 9
0
 public GazeApiManager(IGazeApiReponseListener responseListener, IGazeApiConnectionListener connectionListener)
 {
     this.responseListener = responseListener;
     this.connectionListener = connectionListener;
     requestQueue = new BlockingQueue<String>();
 }
Ejemplo n.º 10
0
 public OutgoingStreamHandler(TcpClient _socket, BlockingQueue<String> _queue, IGazeApiConnectionListener _connectionListener, GazeApiManager _networkLayer)
 {
     this.socket = _socket;
     this.connectionListener = _connectionListener;
     this.networkLayer = _networkLayer;
     this.blockingOutQueue = _queue;
 }