public StudentData[] Join(string name, int idx) { Myfile = new Data(UserHandler); lock (syncObj) { try { if (!Chatter.Contains(name)) { StudentData data = new StudentData(true, name, idx); Chatter.Add(data); callback = OperationContext.Current.GetCallbackChannel <IFileCallBack>(); Console.WriteLine(name); List += Myfile; Console.WriteLine(name); BroadcastMessage(name, idx, "", null, "UserEnter"); StudentData[] list = new StudentData[Chatter.Count]; lock (syncObj) { Chatter.CopyTo(list); } return(list); } else { return(null); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } } }
public bool UpLoadFile(string name, int idx, string filename, byte[] data) { Myfile = new Data(UserHandler); try { FileStream writeFileStream = new FileStream(@"C:\Users\DUMB\Pictures\Saved Pictures\" + filename, FileMode.Create, FileAccess.Write); BinaryWriter dataWriter = new BinaryWriter(writeFileStream); dataWriter.Write(data); writeFileStream.Close(); callback = OperationContext.Current.GetCallbackChannel <IFileCallBack>(); Console.WriteLine(name + idx + filename + data.Length.ToString()); List += Myfile; BroadcastMessage(name, idx, filename, data, "FileSender"); // BroadcastMessage(name, idx, filename, data, "FileSender"); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } }