|
||
|
|
#1 (permalink) |
|
Forum Expert
|
Hello, i am having a problem with a ReadLine. I have a part of the code doing a ReadLine();, but as it awaits for the user to input something, it pauses all other actions the server wants to do. my question is how can i cancel this ReadLine from another script?
Thx for any help.. |
|
|
|
|
|
#2 (permalink) | |
|
Account Terminated
|
Quote:
If you explain what your trying to do, we can help you do it a better way. |
|
|
|
|
|
|
#3 (permalink) |
|
Forum Expert
|
I am making a script that will allow you to do certain commands from the console, instead of logging in to do them. I have the script that will send the Readline once the server is done loading..
Code:
using System;
using System.IO;
using Server;
namespace Server.Misc
{
public class ConsoleShutdown
{
public static void Initialize()
{ EventSink.ServerStarted += new ServerStartedEventHandler(EventSink_ServerStarted); }
public static void EventSink_ServerStarted()
{
Console.WriteLine("What?");
Console.ReadLine();
}
}
}
Last edited by BeneathTheStars; 05-30-2006 at 12:13 PM. |
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
|
Well, if i understand correctly, then they only have a window of time to enter a command( or a number of windows)...
As of now, i have a separate .exe that talks to a script in the Runuo scripts folder. But, i am having a "fun" time trying to get that script to talk to the Server.exe, and not the external .exe i made..if that makes any sense.. |
|
|
|
|
|
#6 (permalink) |
|
Forum Expert
|
The external .exe:
Code:
using System;
using System.Collections;
using System.Text;
using Server;
using Server.CHQ;
namespace Server.Misc
{
class ServerConsole
{
static void Main(string[] args)
{
Console.WriteLine("Whats do you wish to do?");
string ans = (Console.ReadLine()).ToLower();
if (ans == "shutdown")
ConsoleHQ.ShutDown();
if (ans == "restart")
ConsoleHQ.ReStart();
}
}
}
Code:
using System;
using System.IO;
using Server;
using System.Diagnostics;
namespace Server.CHQ
{
public class ConsoleHQ
{
public static void ShutDown()
{
World.Save();
Core.Process.Kill();
}
public static void ReStart()
{
AutoRestart.Initialize();
}
}
}
|
|
|
|
|
|
#9 (permalink) |
|
Forum Expert
|
Old problem new culprit. The line in red pauses the server.exe until it gets its packet.(Console says Remote Started, but doesnt say "2" untill the socket is sent)
Code:
using System;
using System.Net.Sockets;
using System.IO ;
using Server;
namespace Server.Misc
{
public class Echoserver
{
public static void Initialize()
{
TcpListener tcpListener = new TcpListener(1234);
tcpListener.Start();
Console.WriteLine("Remote Started");
Socket socketForClient = tcpListener.AcceptSocket();
Console.WriteLine("2");//debuging
string line = "";
try
{...
|
|
|
|
|
|
#10 (permalink) | |
|
Account Terminated
|
Quote:
You have of course send the require bytes that RunUO expects. You can check out the core for what I mean by this. |
|
|
|
|
|
|
#12 (permalink) |
|
Forum Expert
Join Date: Sep 2002
Age: 23
Posts: 1,472
|
What noobie means:
Code:
// Along with the other namespace declarations
using System.Threading;
...
// Somewhere in your calling method
new Thread(new ThreadStart(ConsoleListen)).Start();
...
// Somewhere else in the class
public static void ConsoleListen()
{
string input = Console.ReadLine();
Console.WriteLine("User Input: {0}", input);
}
|
|
|
|
|
|
#13 (permalink) |
|
Forum Expert
|
Hmm, thx newbie,Ravatar, and Phantom. Ill play with that...looks like i diddnt get deep enough into threading..
![]() Going to take this opportunity to learn windows forms, and im going on vacation, so i should have it all done by the end of this month(with lots of features).. Last edited by BeneathTheStars; 06-01-2006 at 12:01 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|