void ParseServiceMessage(ServiceMessage message) { switch (message.Name) { case ServiceMessageNames.SetVariable.Name: var variableName = message.GetValue(ServiceMessageNames.SetVariable.NameAttribute); var variableValue = message.GetValue(ServiceMessageNames.SetVariable.ValueAttribute); if (!string.IsNullOrWhiteSpace(variableName)) { outputVariables.Set(variableName, variableValue); } break; case ServiceMessageNames.CalamariFoundPackage.Name: CalamariFoundPackage = true; break; case ServiceMessageNames.FoundPackage.Name: var foundPackageId = message.GetValue(ServiceMessageNames.FoundPackage.IdAttribute); var foundPackageVersion = message.GetValue(ServiceMessageNames.FoundPackage.VersionAttribute); var foundPackageHash = message.GetValue(ServiceMessageNames.FoundPackage.HashAttribute); var foundPackageRemotePath = message.GetValue(ServiceMessageNames.FoundPackage.RemotePathAttribute); FoundPackage = new StoredPackage( new PhysicalPackageMetadata { PackageId = foundPackageId, Version = foundPackageVersion, Hash = foundPackageHash }, foundPackageRemotePath); break; case ServiceMessageNames.PackageDeltaVerification.Name: var pdvHash = message.GetValue(ServiceMessageNames.PackageDeltaVerification.HashAttribute); var pdvSize = message.GetValue(ServiceMessageNames.PackageDeltaVerification.SizeAttribute); var pdvRemotePath = message.GetValue(ServiceMessageNames.PackageDeltaVerification.RemotePathAttribute); DeltaError = message.GetValue(ServiceMessageNames.PackageDeltaVerification.Error); if (pdvHash != null) { DeltaVerification = new StoredPackage(new PhysicalPackageMetadata { Hash = pdvHash }, pdvRemotePath); } break; } }
private void Received_DATA(string sender, string[] msg) { Invoke(new ReceivedData(delegate { if (msg[0] == "DATA") { var fileInfo = msg[3].Split('/'); ReceivedFile._sender = msg[1]; ReceivedFile._Receiver = msg[2]; ReceivedFile._FileName = fileInfo[0]; ReceivedFile._Size = int.Parse(fileInfo[1]); ReceivedFile._PacketCnt = int.Parse(fileInfo[2]); ReceivedFile._Data = new byte[ReceivedFile._Size]; ReceivedFile._RemainPacket = int.Parse(fileInfo[3]); // 서버 관리용 파일 관리 정보 StoredPackage SPakage = new StoredPackage(ReceivedFile._sender, ReceivedFile._Receiver, ReceivedFile._FileName, ReceivedFile._Size); if (isServer) { if (ReceivedFile._Receiver == myIP) { // 서버가 수신인 frm_Alarm frmAlarm = new frm_Alarm(ReceivedFile._sender, ReceivedFile._FileName); frmAlarm.Show(); } else { // 클라이언트 -> 서버 -> 수신인 clsMSG.sSender = ReceivedFile._sender; clsMSG.sReceiver = ReceivedFile._Receiver; clsMSG.sHeader = SocketMSG.MESSAGE_TYPE.DATA; FileStream fileStr = new FileStream(ReceivedFile._FileName, FileMode.Create, FileAccess.Write); BinaryWriter writer = new BinaryWriter(fileStr); writer.Write(ReceivedFile._Data, 0, ReceivedFile._Size); fileStr.Close(); // 보낼 파일 SockFileTransfer sockFileTransfer = new SockFileTransfer(); var o_Packet = sockFileTransfer.FileSelect(ReceivedFile._FileName); clsServer.FileSend(clsMSG, o_Packet); } } } })); }