void Server_Started(object sender, AsyncUdpEventArgs e) { CastReceiver cr = sender as CastReceiver; WriteLog($"伺服器已於 {cr.LocalEndPort} 啟動"); WriteLog("已加入監聽的群組:"); foreach (System.Net.Sockets.MulticastOption mo in cr.JoinedGroups) { WriteLog($"-> {mo.Group}"); } }
void Server_DataReceived(object sender, AsyncUdpEventArgs e) { WriteLog("收到資料({0}->{1}) {2} Bytes", e.RemoteEndPoint, e.LocalEndPoint, e.Data.Length); WriteLog(" > : {0}", Encoding.Default.GetString(e.Data)); WriteLog("Hex: {0}", e.Data.ToHexString()); }
void Server_Shutdowned(object sender, AsyncUdpEventArgs e) { WriteLog("伺服器已關閉"); }
void Client_DataSended(object sender, AsyncUdpEventArgs e) { WriteLog("發送資料 {0} Bytes", e.Data.Length); WriteLog(" < : {0}", Encoding.Default.GetString(e.Data)); WriteLog("Hex: {0}", e.Data.ToHexString()); }
void Server_OnDataReceived(object sender, AsyncUdpEventArgs e) { WriteLog("收到資料 {0} Bytes 來自 {1}", e.Data.Length, e.RemoteEndPoint); WriteLog(" > : {0}", Encoding.Default.GetString(e.Data)); WriteLog("Hex: {0}", e.Data.ToHexString()); }
void Server_OnException(object sender, AsyncUdpEventArgs e) { WriteLog("M:伺服器發生錯誤:{0}", e.Exception.Message); }
void Server_OnStarted(object sender, AsyncUdpEventArgs e) { WriteLog("M:伺服器已於 {0} 啟動", _Server.Socket.LocalEndPoint); }
void Server_OnShutdown(object sender, AsyncUdpEventArgs e) { WriteLog("M:伺服器已關閉"); }