protected override void WriteMessage(OutgoingMessage outMessage)
 {
     propertyMap.OldWriteMessage(outMessage);
 }
        public TestClass()
        {
            SetupDebug();

            // const int ServerPort = 200;
            const int ServerPort = 5001;
            const int ClientPort = 6666;

            IPHostEntry IPHost = Dns.GetHostEntry("cedeno-dxp.corp.multiverse.net");
            IPAddress[] addr = IPHost.AddressList;
            IPEndPoint sendpt = new IPEndPoint(addr[0], ServerPort);

            RdpClient rdpClient = new RdpClient(ClientPort, 100, 1000, true);
            RdpClient rdpClient2 = new RdpClient(ClientPort + 1, 100, 1000, false);
            //RdpServer rdpServer = new RdpServer(ServerPort, 100, 1000, true);

            RdpConnection rdpClientConn = rdpClient.Connect(sendpt);
            RdpConnection rdpClientConn2 = rdpClient2.Connect(sendpt);
            // RdpConnection rdpServerConn = rdpServer.Accept();

            rdpClientConn.WaitForState(ConnectionState.Open);
            rdpClientConn2.WaitForState(ConnectionState.Open);

            //            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            OutgoingMessage outMessage = new OutgoingMessage();
            outMessage.Write("Good morning");
            outMessage.Send(rdpClientConn);

            outMessage.Send(rdpClientConn2);

            // byte[] msg = Encoding.ASCII.GetBytes("Test");

            // rdpClientConn.Send(msg);
            // rdpClientConn.Send(msg);
            // rdpClientConn.Send(msg);

            IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
            IncomingMessage inMessage;

            inMessage = new IncomingMessage(rdpClientConn);
            Console.WriteLine("Got message: {0}", inMessage.ReadString());

            inMessage = new IncomingMessage(rdpClientConn2);
            Console.WriteLine("Got message2: {0}", inMessage.ReadString());

            //            for (int i = 0; i < 3; ++i) {
            //                byte[] rcvdMessage = rdpServerConn.Receive(ref remoteEP);
            //                Console.WriteLine("Server got message from {1}: '{0}'",
            //                                  Encoding.ASCII.GetString(rcvdMessage), remoteEP);
            //                rdpServerConn.Send(msg);
            //            }
            //
            //            for (int i = 0; i < 3; ++i) {
            //                byte[] rcvdMessage = rdpClientConn.Receive(ref remoteEP);
            //                Console.WriteLine("Client got message from {1}: '{0}'",
            //                                  Encoding.ASCII.GetString(rcvdMessage), remoteEP);
            //            }
            //
            //            rdpServerConn.Close();

            Thread.Sleep(100);

            //            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            Thread.Sleep(31000);

            //            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            FinishDebug();

            //rdpConn.Open(false, 1, 2, 3, 4, true);
            //rdpConn.Send(new Multiverse.Network.Rdp.RdpPacket(50));
            //this.Hide();
            //this.WindowState = FormWindowState.Minimized;
        }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
     outMessage.Write(offer1.Count);
     foreach (InvItemInfo item in offer1) {
         outMessage.Write(item.itemId);
         outMessage.Write(item.name);
         outMessage.Write(item.icon);
     }
     outMessage.Write(accepted1);
     foreach (InvItemInfo item in offer2) {
         outMessage.Write(item.itemId);
         outMessage.Write(item.name);
         outMessage.Write(item.icon);
     }
     outMessage.Write(accepted2);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(uiModules.Count);
     foreach (string uiModule in uiModules)
         outMessage.Write(uiModule);
     if (keyBindingsFile != null)
         outMessage.Write(keyBindingsFile);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(objectId);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(timestamp);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(orientation);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     int numEntries = newSoundEntries.Count + freeSoundEntries.Count;
     if (clearSounds)
         numEntries++;
     outMessage.Write(numEntries);
     foreach (KeyValuePair<string, PropertyMap> kvp in newSoundEntries) {
         outMessage.Write("on");
         outMessage.Write(kvp.Key);
         kvp.Value.WriteMessage(outMessage);
     }
     foreach (string soundName in freeSoundEntries) {
         outMessage.Write("off");
         outMessage.Write(soundName);
     }
     if (clearSounds)
         outMessage.Write("clear");
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(entries.Count);
     foreach (AbilityEntry entry in entries) {
         outMessage.Write(entry.name);
         outMessage.Write(entry.icon);
         outMessage.Write(entry.category);
     }
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(modelInfo.Count);
     foreach (MeshInfo meshInfo in modelInfo)
         meshInfo.WriteMessage(outMessage);
 }
 /// <summary>
 ///   This method is used by the loopback network helper for debugging.
 /// </summary>
 /// <param name="outMessage"></param>
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
     outMessage.Write(name);
     outMessage.Write(location);
     outMessage.Write(orientation);
     outMessage.Write(scale);
     outMessage.Write((int)objectType);
     outMessage.Write(followTerrain);
     outMessage.Write(direction);
     outMessage.Write(lastInterp);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
     outMessage.Write((int)lightType);
     outMessage.Write(name);
     outMessage.Write(diffuse);
     outMessage.Write(specular);
     outMessage.Write(attenuationRange);
     outMessage.Write(attenuationConstant);
     outMessage.Write(attenuationLinear);
     outMessage.Write(attenuationQuadratic);
     switch (lightType)
     {
         case LightNodeType.Point:
             outMessage.Write(location);
             break;
         case LightNodeType.Directional:
             outMessage.Write(orientation);
             break;
         case LightNodeType.Spotlight:
             outMessage.Write(location);
             outMessage.Write(orientation);
             outMessage.Write(spotlightInnerAngle);
             outMessage.Write(spotlightOuterAngle);
             outMessage.Write(spotlightFalloff);
             break;
         default:
             throw new Exception("Invalid light node type: " + lightType);
     }
 }
        protected override void WriteMessage(OutgoingMessage outMessage)
        {
            outMessage.Write(name);
            outMessage.Write(icon);
            outMessage.Write(description);

            outMessage.Write(cooldowns.Count);
            foreach (string entry in cooldowns)
                outMessage.Write(entry);

            outMessage.Write(properties.Count);
            foreach (string key in properties.Keys) {
                outMessage.Write(key);
                outMessage.Write(properties[key]);
            }
        }
 public void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(meshFile);
     outMessage.Write(submeshList.Count);
     foreach (SubmeshInfo submeshInfo in submeshList) {
         outMessage.Write(submeshInfo.SubmeshName);
         outMessage.Write(submeshInfo.MaterialName);
         outMessage.Write(submeshInfo.CastShadows);
         outMessage.Write(submeshInfo.ReceiveShadows);
     }
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(worldId);
     outMessage.Write(characterId);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(material);
 }
 // This is used for CharacterRequest, CharacterCreateRequest
 // and CharacterDeleteRequest but nothing else.
 public void OldWriteMessage(OutgoingMessage outMessage)
 {
     List<String> propStrings = new List<string>();
     int propCount = 0;
     foreach (string key in properties.Keys) {
         object value = properties[key];
         if (value is string) {
             propStrings.Add(key);
             propStrings.Add("S");
             propStrings.Add((string)value);
             propCount++;
         } else if (value is bool) {
             propStrings.Add(key);
             propStrings.Add("B");
             propStrings.Add(value.ToString());
             propCount++;
         } else if (value is int) {
             propStrings.Add(key);
             propStrings.Add("I");
             propStrings.Add(value.ToString());
             propCount++;
         } else if (value is long) {
             propStrings.Add(key);
             propStrings.Add("L");
             propStrings.Add(value.ToString());
             propCount++;
         } else if (value is float) {
             propStrings.Add(key);
             propStrings.Add("F");
             propStrings.Add(value.ToString());
             propCount++;
         } else if (value is Vector3) {
             propStrings.Add(key);
             propStrings.Add("V");
             propStrings.Add(value.ToString());
             propCount++;
         } else if (value is Quaternion) {
             propStrings.Add(key);
             propStrings.Add("Q");
             propStrings.Add(value.ToString());
             propCount++;
         } else {
             LogManager.Instance.Write("PropertyMap: unknown type, skipping key: {0}", key);
         }
     }
     outMessage.Write(propCount);
     foreach (string entry in propStrings)
         outMessage.Write(entry);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(states.Count);
     foreach (string key in states.Keys) {
         outMessage.Write(key);
         outMessage.Write(states[key]);
     }
 }
 public void WriteMessage(OutgoingMessage outMessage)
 {
     EncodedObjectIO io = new EncodedObjectIO(outMessage);
     io.WritePropertyMap(properties);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(configKind);
     outMessage.Write(configString);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(questId);
     outMessage.Write(title);
     outMessage.Write(description);
     outMessage.Write(objective);
     outMessage.Write(rewardItems.Count);
     foreach (ItemEntry reward in rewardItems) {
         outMessage.Write(reward.name);
         outMessage.Write(reward.icon);
         outMessage.Write(reward.count);
     }
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
     outMessage.Write(accepted);
     outMessage.Write(cancelled);
     outMessage.Write(offer.Count);
     foreach (long itemOid in offer) {
         outMessage.Write(itemOid);
     }
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
     outMessage.Write(questId);
     outMessage.Write(accepted);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     base.WriteMessage(outMessage);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(questId);
     outMessage.Write(objectives.Count);
     foreach (string objective in objectives)
         outMessage.Write(objective);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(version);
     outMessage.Write(authToken);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(worldName);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(color);
 }
 protected override void WriteMessage(OutgoingMessage outMessage)
 {
     outMessage.Write(name);
     outMessage.Write(points.Count);
     foreach (Vector3 point in points)
         outMessage.Write(new IntVector3(point));
     outMessage.Write(halfWidth);
 }
 public static void RunOutgoing()
 {
     SocketAddress addr = null;
     int sentCount = 0;
     try {
         int runningCounter = 0;
         long lastTime = CurrentTime;
         for (int i=0; i<messageCount; i++) {
             long currentTime = CurrentTime;
             long interval = currentTime - lastTime;
             if (interval > 1000) {
                 lastTime = currentTime;
                 Logit("Sent " + sentCount + " messages" + " in the last " + interval + "ms");
                 sentCount = 0;
             }
             OutgoingMessage outMessage = new OutgoingMessage();
             Debug.Assert(rdpConnection != null, "In TestRDPClient.RunOutgoing, rdpConnection is null!");
             outMessage.Write("Hello World from CLIENT! - MSG " + runningCounter++);
             bool trying = true;
             while (trying) {
                 try {
                     outMessage.Send(rdpConnection);
                     trying = false;
                 }
                 catch (Exception e) {
                     if (e.Message == "Error - insufficient resources to send data")
                         Thread.Sleep(10);
                     else
                         throw;
                 }
             }
             sentCount++;
         }
         Console.WriteLine("RunOutgoing sent a total of " + messageCount + " messages");
     }
     catch(Exception e) {
         Logit("TestRDPClient.RunOutgoing got error: " + e.ToString());
         Logit("TestRDPClient.RunOutgoing sentCount = " + sentCount);
     }
 }
        public TestClass()
        {
            SetupDebug();

            // const int ServerPort = 200;
            const int ServerPort = 5001;
            const int ClientPort = 6666;

            IPHostEntry IPHost = Dns.GetHostEntry("cedeno-dxp.corp.multiverse.net");

            IPAddress[] addr   = IPHost.AddressList;
            IPEndPoint  sendpt = new IPEndPoint(addr[0], ServerPort);


            RdpClient rdpClient  = new RdpClient(ClientPort, 100, 1000, true);
            RdpClient rdpClient2 = new RdpClient(ClientPort + 1, 100, 1000, false);
            //RdpServer rdpServer = new RdpServer(ServerPort, 100, 1000, true);

            RdpConnection rdpClientConn  = rdpClient.Connect(sendpt);
            RdpConnection rdpClientConn2 = rdpClient2.Connect(sendpt);

            // RdpConnection rdpServerConn = rdpServer.Accept();

            rdpClientConn.WaitForState(ConnectionState.Open);
            rdpClientConn2.WaitForState(ConnectionState.Open);

//            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            OutgoingMessage outMessage = new OutgoingMessage();

            outMessage.Write("Good morning");
            outMessage.Send(rdpClientConn);

            outMessage.Send(rdpClientConn2);

            // byte[] msg = Encoding.ASCII.GetBytes("Test");

            // rdpClientConn.Send(msg);
            // rdpClientConn.Send(msg);
            // rdpClientConn.Send(msg);

            IPEndPoint      remoteEP = new IPEndPoint(IPAddress.Any, 0);
            IncomingMessage inMessage;

            inMessage = new IncomingMessage(rdpClientConn);
            Console.WriteLine("Got message: {0}", inMessage.ReadString());

            inMessage = new IncomingMessage(rdpClientConn2);
            Console.WriteLine("Got message2: {0}", inMessage.ReadString());

            //            for (int i = 0; i < 3; ++i) {
//                byte[] rcvdMessage = rdpServerConn.Receive(ref remoteEP);
//                Console.WriteLine("Server got message from {1}: '{0}'",
//                                  Encoding.ASCII.GetString(rcvdMessage), remoteEP);
//                rdpServerConn.Send(msg);
//            }
//
//            for (int i = 0; i < 3; ++i) {
//                byte[] rcvdMessage = rdpClientConn.Receive(ref remoteEP);
//                Console.WriteLine("Client got message from {1}: '{0}'",
//                                  Encoding.ASCII.GetString(rcvdMessage), remoteEP);
//            }
//
//            rdpServerConn.Close();

            Thread.Sleep(100);

//            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            Thread.Sleep(31000);

//            Console.WriteLine("Server State = " + rdpServerConn.ConnectionState);
            Console.WriteLine("Client State = " + rdpClientConn.ConnectionState);

            FinishDebug();

            //rdpConn.Open(false, 1, 2, 3, 4, true);
            //rdpConn.Send(new Multiverse.Network.Rdp.RdpPacket(50));
            //this.Hide();
            //this.WindowState = FormWindowState.Minimized;
        }