Skip to content

Commit 20d00c9

Browse files
[p2p] - fix typo
1 parent 46e1e6a commit 20d00c9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
## How it works
66

7-
- Compile and Open `p2p.exe` as admin in 2 different PC's
7+
- Compile and Open `p2p.exe` as admin in 2 different PC's.
88

99
![p2p-exe](img/p2p-exe.png)
1010

1111
- Copy the `My Lan or Wan IP` and communicate it to other peer.
1212

1313
![p2p-connection](img/p2p-connection.png)
1414

15-
- So the 2 peers have now the 2 endpoint to connect to, so press on both `Connect`.
15+
- The 2 peers have now the 2 endpoint to connect to, so press on both `Connect`.
1616

1717
- The 2 peers now are able to `sent messages` or take the `Remote Desktop Control` between them.
1818

@@ -21,7 +21,7 @@
2121
</br >
2222

2323
It's use [UDT protocol](https://en.wikipedia.org/wiki/UDP-based_Data_Transfer_Protocol)
24-
and thanks to `rendezvous` connection, it should be able to `bypass all firewall rules` etc, like a small concepts of `TeamViewer` at 0 cost!
24+
and thanks to `rendezvous` connection, it should be able to `bypass most firewall rules`, like a small concept of `TeamViewer` at 0 cost!
2525

2626
![p2p-logic](img/p2p-logic.png)
2727

p2pconn/StreamingDesktop/RemoteDesktop.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ private static void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
107107
GetCursorState();
108108
bmpData = ScreenCap.LockBits(new System.Drawing.Rectangle(0, 0, ScreenCap.Width, ScreenCap.Height),
109109
ImageLockMode.ReadWrite, ScreenCap.PixelFormat);
110-
using (MemoryStream MotionStream = new MemoryStream(10000000)) // 10000000
110+
// 10000000 allocate already enough memory to make it fast
111+
using (MemoryStream MotionStream = new MemoryStream(100000000))
111112
{
112113
if (UnsafeMotionCodec == null) throw new Exception("StreamCodec can not be null.");
113114
UnsafeMotionCodec.CodeImage(bmpData.Scan0,
114115
new Rectangle(0, 0, ScreenCap.Width, ScreenCap.Height),
115116
new Size(ScreenCap.Width, ScreenCap.Height),
116117
ScreenCap.PixelFormat, MotionStream);
118+
// 4 bytes = inactivity no motion detection
117119
if (MotionStream.Length > 4)
118120
{
119121
// GlobalVariables.Root.Writetxtchatrom("Green", "Before no compressed: " + MotionStream.ToArray().Length);
@@ -122,20 +124,20 @@ private static void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
122124
SenderReceiver.SendMessage("b|" + Tipo + "|" + tempBytes.Length);
123125
SenderReceiver.client.Send(tempBytes, 0, tempBytes.Length);
124126
Array.Clear(tempBytes, 0, tempBytes.Length);
125-
}
127+
}
126128
}
127129
ScreenCap.UnlockBits(bmpData);
128130
ScreenCap.Dispose();
129131
GC.Collect();
130132
// GlobalVariables.Root.Writetxtchatrom("Green", "time: " + time.ElapsedMilliseconds + " ms");
131133
// time.Stop();
132-
}
134+
}
133135
catch (Exception ex)
134136
{
135137
GlobalVariables.Root.Writetxtchatrom("Red", "Stop Sharing Desktop: " + ex.Message);
136138
StopDesktop();
137139
GC.Collect();
138-
}
140+
}
139141
}
140142

141143
private static Bitmap ScreenCap

0 commit comments

Comments
 (0)