Answer the question
In order to leave comments, you need to log in
Websocket: accepting a message and writing part of it to a separate variable. How to implement?
I have a server and a client. Communicate via websocket.
One of them sends such a message (it does not matter who), for example:
на C#
string CurPos = "F1";
string NewPos = "F2";
con.Send("Change position: " + CurPos + "-" + NewPos);
string newMsg = "Change position: F1-F2";
Answer the question
In order to leave comments, you need to log in
Как сделать, чтобы получаемые символы на определенных местах записывались в, например, заранее оглашенные переменные?
string[] tokens = Regex.Split("Change position: F1-F2", @"(: )|(-)", RegexOptions.ExplicitCapture);
if( tokens.Length == 3 && string.Equals(tokens[0], "Change position") )
{
curPos = tokens[1];
newPos = tokens[2];
} else {
// прислали какую-то непонятную хрень...
}
string[] tokens = "Change position:F1:F2".Split(':');
if( tokens.Length == 3 && string.Equals(tokens[0], "Change position") )
{
curPos = tokens[1];
newPos = tokens[2];
} else {
// прислали какую-то непонятную хрень...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question