changed tcpserver signature
This commit is contained in:
parent
d162f6dc1f
commit
8020a76c41
13
AST.cs
13
AST.cs
|
@ -1054,10 +1054,15 @@ namespace langtest
|
|||
Expression listenIp = expressions[0];
|
||||
Expression listenPort = expressions[1];
|
||||
VariableGetValueNode? stream_name = expressions[2] as VariableGetValueNode;
|
||||
Expression exp = expressions[3];
|
||||
VariableGetValueNode? ip_name = expressions[3] as VariableGetValueNode;
|
||||
|
||||
Expression exp = expressions[4];
|
||||
|
||||
if(stream_name == null) throw new Exception("You must use identifier at positional arg #3 (starting from 1)");
|
||||
if(ip_name == null) throw new Exception("You must use identifier at positional arg #4 (starting from 1)");
|
||||
string name = stream_name.Name;
|
||||
//tcpserver("0.0.0.0",4202,strm,{})
|
||||
string ipname = ip_name.Name;
|
||||
//tcpserver("0.0.0.0",4202,strm,ip,{})
|
||||
TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse(state.BoxToString(listenIp.Evaluate(state))),(int)listenPort.Evaluate(state)));
|
||||
listener.Start();
|
||||
while(true)
|
||||
|
@ -1067,6 +1072,10 @@ namespace langtest
|
|||
var s=state.NewScope();
|
||||
long str =s.CreateStream(stream);
|
||||
s.SetVariable(name,str);
|
||||
string? ip=clt.Client?.RemoteEndPoint?.ToString();
|
||||
if(string.IsNullOrWhiteSpace(ip)) ip="";
|
||||
|
||||
s.SetVariable(ipname,s.CreateBox(ip));
|
||||
exp.Execute(s);
|
||||
s.CloseStream(str);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue