1010
1111namespace Microsoft . Azure . SignalR . Samples . Management
1212{
13- class Program
13+ public class Program
1414 {
15- static void Main ( string [ ] args )
15+ public static void Main ( string [ ] args )
1616 {
17- var app = new CommandLineApplication ( ) ;
18- app . FullName = "Azure SignalR Management Sample: Message Publisher" ;
17+ var app = new CommandLineApplication
18+ {
19+ FullName = "Azure SignalR Management Sample: Message Publisher"
20+ } ;
1921 app . HelpOption ( "--help" ) ;
2022 app . Description = "Message publisher using Azure SignalR Service Management SDK." ;
2123
@@ -28,7 +30,7 @@ static void Main(string[] args)
2830 . Build ( ) ;
2931
3032
31- app . OnExecute ( async ( ) =>
33+ app . OnExecute ( async ( ) =>
3234 {
3335 var connectionString = connectionStringOption . Value ( ) ?? configuration [ "Azure:SignalR:ConnectionString" ] ;
3436
@@ -82,8 +84,8 @@ private static async Task StartAsync(MessagePublisher publisher)
8284
8385 if ( args . Length == 2 && args [ 0 ] . Equals ( "broadcast" ) )
8486 {
85- Console . WriteLine ( $ "broadcast message '{ args [ 1 ] } '") ;
8687 await publisher . SendMessages ( args [ 0 ] , null , args [ 1 ] ) ;
88+ Console . WriteLine ( $ "broadcast message '{ args [ 1 ] } '") ;
8789 }
8890 else if ( args . Length == 4 && args [ 0 ] . Equals ( "send" ) )
8991 {
@@ -96,10 +98,21 @@ private static async Task StartAsync(MessagePublisher publisher)
9698 var preposition = args [ 1 ] == "add" ? "to" : "from" ;
9799 Console . WriteLine ( $ "{ args [ 1 ] } user '{ args [ 2 ] } ' { preposition } group '{ args [ 3 ] } '") ;
98100 }
101+ else if ( args . Length == 3 && args [ 0 ] == "close" )
102+ {
103+ await publisher . CloseConnection ( args [ 1 ] , args [ 2 ] ) ;
104+ Console . WriteLine ( $ "Close connection '{ args [ 1 ] } ' because '{ args [ 2 ] } '") ;
105+ }
106+ else if ( args . Length == 3 && args [ 0 ] == "checkexist" )
107+ {
108+ var exist = await publisher . CheckExist ( args [ 1 ] . ToLowerInvariant ( ) , args [ 2 ] ) ;
109+ Console . WriteLine ( exist ? $ "{ args [ 1 ] } '{ args [ 2 ] } ' exists." : $ "{ args [ 1 ] } '{ args [ 2 ] } ' does not exist.") ;
110+ }
99111 else
100112 {
101113 Console . WriteLine ( $ "Can't recognize command { argLine } ") ;
102114 }
115+ Console . Write ( "> " ) ;
103116 }
104117 }
105118 finally
@@ -110,16 +123,21 @@ private static async Task StartAsync(MessagePublisher publisher)
110123
111124 private static void ShowHelp ( )
112125 {
113- Console . WriteLine (
114- "*********Usage*********\n " +
115- "send user <User Id> <Message>\n " +
116- "send users <User Id List (Seperated by ',')> <Message>\n " +
117- "send group <Group Name> <Message>\n " +
118- "send groups <Group List (Seperated by ',')> <Message>\n " +
119- "usergroup add <User Id> <Group Name>\n " +
120- "usergroup remove <User Id> <Group Name>\n " +
121- "broadcast <Message>\n " +
122- "***********************" ) ;
126+ Console . Write (
127+ @"*********Usage*********
128+ send user <User Id> <Message>
129+ send users <User Id List (Seperated by ',')> <Message>
130+ send group <Group Name> <Message>
131+ send groups <Group List (Seperated by ',')> <Message>
132+ usergroup add <User Id> <Group Name>
133+ usergroup remove <User Id> <Group Name>
134+ broadcast <Message>
135+ close <Connection ID> <Reason>
136+ checkexist connection <Connection ID>
137+ checkexist user <User ID>
138+ checkexist group <Group Name>
139+ ***********************
140+ > " ) ;
123141 }
124142
125143 private static void MissOptions ( )
0 commit comments